Factors and Constraints
Integer and enum factors
This page lists the built-in methods and operators for creating random variables of type int and of type enum. For both static methods and operators, you can often pass in random variables as arguments e.g.
Variable<int> instead of int. For compactness, this is not shown in the syntax below.
These methods provide a convenient short alternative to using
Variable<T>.Factor and passing in the factor method, as described on this page.
A distribution factor creates a random variable from a parameterised distribution.
||Creates an int random variable from supplied array or vector of probabilities (which must add up to 1). The variable can take values between 0 and N-1 where N is the length of the array/vector.|
||Creates an int random variable from supplied array or vector of log probabilities. Equivalent to
||Creates an int random variable which can take values from 0 to size-1 with equal probability.|
||Creates an enum random variable where the probability of each enum value is given by the specified array or vector. TEnum specifies the enum type.|
||Creates an enum random variable with equal probability of taking each possible value of the enumeration. TEnum specifies the enum type.|
||Creates an int random variable which has a Binomial distribution with the specified probability of success per trial and number of trials|
||Creates an int random variable which has a Poisson distribution with the specified mean.|
Arithmetic operations are supported via operator overloads or static methods.
|Plus||a + b||Creates an int random variable equal to the sum of
|Multiply||a * b||Creates an intrandom variable equal to the product of
||Creates an int random variable which counts up the number of elements in the array that are true.|
||Creates an int random variable corresponding to an enum random variable. The returned variable can be used as the condition for a Switch or Case block.|