Skip to Content

Special Functions

If(c, t, e)

  • Description: Conditional instruction: if c is True then t else e.

  • 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.

2556115

Switch(s, ki, vi, …, d)

  • Description: Branch instruction. According to the value ki that s can take, the corresponding value vi is returned. If no ki matches, the default value d is returned.

  • Number of parameters: ≥ 4

  • Parameter type: all, all, all, …, all. The parameters s and ki must have the same type (or be comparable, e.g. integer and real); likewise for vi and d.

  • Result type: The common type of vi and d. 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 k or fewer occurrences of an event of probability p among n independent 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 min and less than max. 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 m and standard deviation s from this random number generator’s sequence.
  • Number of parameters: 2
  • Parameter type: numerical, numerical
  • Result type: real