Boolean factors
This page lists the builtin methods and operators for creating random variables of type
bool. For both static methods and operators, you can often pass in random variables as arguments e.g.
Variable<bool> instead of
bool. 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.
Distribution Factors
A distribution factor creates a random variable from a parameterised distribution.
Distribution 
Syntax 
Description 
Bernoulli 
Variable.Bernoulli(double probTrue) 
Creates a boolean random variable from the probability of being true P(true). 
Bernoulli 
Variable.BernoulliFromLogOdds(double logOdds) 
Creates a boolean random variable from the log odds i.e. log P(true)/P(false). Equivalent to Variable.Bernoulli(Variable.Logistic(logOdds)). 
Logical Operations
Logical operations are supported via operator overloads or static methods.
Operation 
Syntax 
Description 
And 
a & b

Creates a boolean random variable which is true if both a and b are true. 
Or 
a  b 
Creates a boolean random variable which is true if either a or b are true. 
Not 
!a 
Creates a boolean random variable which is true if a is false. 
AllTrue 
Variable.AllTrue(bool[] array) Variable.AllTrue(IList<bool> array) 
Creates a boolean random variable which is true if all the elements of array are true. In other words, this is a Nvalued AND. Where the array has length two, & should be used instead. 
Comparison Operations
Comparison operations are supported via operator overloads or static methods.
Operation 
Syntax 
Description 
Equals 
a==b 
Creates a boolean random variable which is true if a and b are equal. 
Not equals 
a!=b 
Creates a boolean random variable which is true if a and b are not equal. 
Greater than / less than 
a>b, a<b a>=b, a<=b Note: a and b must be both double or both int 
Creates a boolean random variable which is true if a is greater than/less than/greater than or equal to/less than or equal to b. 
IsPositive 
Variable.IsPositive(double x) 
Creates a boolean random variable which is true if x is positive. 
IsBetween 
Variable.IsBetween(double x, double lowerBound, double upperBound) 
Creates a boolean random variable which is true if lowerBound <= x < upperBound. 