Cross-nested logit
Implements the probability generating function and the CDF of a cross-nested logit model
biogeme.cnl module
Implements the probability generating function and the CDF of a cross-nested logit model. This module is not used by Biogeme itself. It is essentially used for external use. It has been mainly implemented to verify the analytical derivatives of these functions.
- author:
Michel Bierlaire
- date:
Fri Apr 22 09:39:49 2022
- biogeme.cnl.cnl_CDF(alternatives, nests)[source]
Cumulative distribution function and its derivatives
- Parameters:
alternatives (list(int)) – a list of alternatives in a given order. In principle, the alternative ids should be integers (to be consistent with Biogeme), but it may be actually be any object for this specific function.
nests (tuple) –
a tuple containing as many items as nests. Each item is also a tuple containing two items:
an object of type biogeme.expressions. expr.Expression representing the nest parameter,
a dictionary mapping the alternative ids with the cross-nested parameters for the corresponding nest. If an alternative is missing in the dictionaray, the corresponding alpha is set to zero.
Example:
alphaA = {1: alpha1a, 2: alpha2a, 3: alpha3a, 4: alpha4a, 5: alpha5a, 6: alpha6a} alphaB = {1: alpha1b, 2: alpha2b, 3: alpha3b, 4: alpha4b, 5: alpha5b, 6: alpha6b} nesta = MUA, alphaA nestb = MUB, alphaB nests = nesta, nestb
- Returns:
function that calculates the CDF, and its first and second derivatives.
- Return type:
f, g, H = fct(np.array(float))
- biogeme.cnl.cnl_G(alternatives, nests)[source]
Probability generating function and its derivatives
- Parameters:
alternatives (list(int)) – a list of alternatives in a given order. In principle, the alternative ids should be integers (to be consistent with Biogeme), but it may be actually be any object for this specific function.
nests (tuple) –
a tuple containing as many items as nests. Each item is also a tuple containing two items:
an object of type biogeme.expressions. expr.Expression representing the nest parameter,
a dictionary mapping the alternative ids with the cross-nested parameters for the corresponding nest. If an alternative is missing in the dictionary, the corresponding alpha is set to zero.
Example:
alphaA = {1: alpha1a, 2: alpha2a, 3: alpha3a, 4: alpha4a, 5: alpha5a, 6: alpha6a} alphaB = {1: alpha1b, 2: alpha2b, 3: alpha3b, 4: alpha4b, 5: alpha5b, 6: alpha6b} nesta = MUA, alphaA nestb = MUB, alphaB nests = nesta, nestb
- Returns:
function that calculates the G function, and its first and second derivatives.
- Return type:
f, g, H = fct(np.array(float))