Special Functions
If(c, t, e)
-
Description: Conditional instruction: if
cis True thentelsee. -
Number of parameters: 3
-
Parameter type: boolean, all, all. The last two parameters must be of the same type (or comparable, e.g. integer and real).
-
Result type: The common type of the last two parameters. If one is real and the other integer, the result type is real.
Example
The following probability distributions correspond to:
P(?Opinion? | ?Note?) =
If(?Opinion? == "Very Weak", Normal(?Note?, 0, 3.5),
If(?Opinion? == "Weak", Normal(?Note?, 7, 3),
If(?Opinion? == "Fair", Normal(?Note?, 10, 3),
If(?Opinion? == "Good", Normal(?Note?, 13, 3),
Normal(?Note?, 20, 3.5)))))where Opinion is a Discrete variable that has 5 states (Very weak, Weak, Fair, Good, Very good) and Note is a Discrete variable with 21 integer states from 0 to 20.
Switch(s, ki, vi, …, d)
-
Description: Branch instruction. According to the value
kithatscan take, the corresponding valueviis returned. If nokimatches, the default valuedis returned. -
Number of parameters: ≥ 4
-
Parameter type: all, all, all, …, all. The parameters
sandkimust have the same type (or be comparable, e.g. integer and real); likewise forviandd. -
Result type: The common type of
viandd. If one is real and the other integer, the result type is real.
Example
The following probability distributions correspond to:
P(?Opinion? | ?Note?) =
Switch(?Opinion?,
"Very Weak", Normal(?Note?, 0, 3.5),
"Weak", Normal(?Note?, 7, 3),
"Fair", Normal(?Note?, 10, 3),
"Good", Normal(?Note?, 13, 3),
Normal(?Note?, 20, 3.5))where Opinion is a Discrete variable that has 5 states (Very weak, Weak, Fair, Good, Very good) and Note is a Discrete variable with 21 integer states from 0 to 20.
CumulBinomial(k, n, p)
- Description: Normalized cumulated probability of ending up with
kor fewer occurrences of an event of probabilitypamongnindependent experiments. - Number of parameters: 3
- Parameter type: integer, integer, numerical
- Result type: real
RandomUniform(min, max)
- Description: Returns a real value greater than or equal to
minand less thanmax. Returned values are pseudo-random, with an (approximately) uniform distribution over that range. - Number of parameters: 2
- Parameter type: numerical, numerical
- Result type: real
RandomGaussian(m, s)
- Description: Returns the next pseudo-random, Gaussian (“normally”) distributed real value with mean
mand standard deviationsfrom this random number generator’s sequence. - Number of parameters: 2
- Parameter type: numerical, numerical
- Result type: real