Class extracting an expression from a dictionary. More...
Public Member Functions | |
def | __init__ |
def | getExpression |
Public Attributes | |
prob | |
choice | |
default | |
operatorIndex |
Class extracting an expression from a dictionary.
A typical example consists in returning the probability of a chosen alternative in a choice model. Consider the following dictionary:
P = { 1: exp(V1) / (exp(V1)+exp(V2)+exp(V3)), 2: exp(V2) / (exp(V1)+exp(V2)+exp(V3)), 3: exp(V3) / (exp(V1)+exp(V2)+exp(V3))}
and assume that the variable Choice in the data file contains the identifier of the chosen alternative of the corresponding observation, that is 1, 2 or 3. Then, the probability of the chosen alternative is given by
chosenProba = Elem(P,Choice)
If the result of "Choice" does not correspond to any valid entry in the dictionary, a warning is issued and the value of the default expression is returned. The warning is issued because this situation is usually not wanted by the user. To turn off the warning, set the parameter warnsForIllegalElements to 0.
def bio_expression::Elem::__init__ | ( | self, | |
dictionary, | |||
key, | |||
default = Numeric(0) |
|||
) |
dictionary | A dictionary (see Python documentation) such that the indices are numerical values that can match the result of an expression |
key | expression identifying the entry in the dictionary If the result of key does not correspond to any valid entry in the dictionary, the value of the default expression is returned. This argument is optional. If omitted, the default value is 0. |
def bio_expression::Elem::getExpression | ( | self ) |
Reimplemented from bio_expression::Expression.
Reimplemented from bio_expression::Expression.