""" Implements the logit model.:author: Michel Bierlaire:date: Wed Oct 25 08:43:26 2023"""importloggingfrombiogeme.expressionsimport(Expression,LogLogit,exp,ExpressionOrNumeric,)logger=logging.getLogger(__name__)
[docs]defloglogit(util:dict[int,ExpressionOrNumeric],av:dict[int,ExpressionOrNumeric]|None,i:ExpressionOrNumeric,)->Expression:"""The logarithm of the logit model The model is defined as .. math:: \\frac{a_i e^{V_i}}{\\sum_{i=1}^J a_j e^{V_j}} :param util: dict of objects representing the utility functions of each alternative, indexed by numerical ids. :param av: dict of objects representing the availability of each alternative (:math:`a_i` in the above formula), indexed by numerical ids. Must be consistent with util, or None. In this case, all alternatives are supposed to be always available. :param i: id of the alternative for which the probability must be calculated. :return: choice probability of alternative number i. """returnLogLogit(util,av,i)
[docs]deflogit(util:dict[int,ExpressionOrNumeric],av:dict[int,ExpressionOrNumeric]|None,i:ExpressionOrNumeric,)->Expression:"""The logit model The model is defined as .. math:: \\frac{a_i e^{V_i}}{\\sum_{i=1}^J a_j e^{V_j}} :param util: dict of objects representing the utility functions of each alternative, indexed by numerical ids. :param av: dict of objects representing the availability of each alternative (:math:`a_i` in the above formula), indexed by numerical ids. Must be consistent with util, or None. In this case, all alternatives are supposed to be always available. :param i: id of the alternative for which the probability must be calculated. :return: choice probability of alternative number i. """returnexp(LogLogit(util,av,i))