Class Variable
A variable in a model
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Models
Assembly: Microsoft.ML.Probabilistic.Compiler.dll
Syntax
public abstract class Variable : IVariable, IModelExpression, CanGetContainers, HasObservedValue
Remarks
Variables can be base or derived. A base Variable is explicitly declared as a variable in MSL.
A derived Variable is simply an expression built from variables.
For example, the expression a[i] is a derived Variable called an item variable.
Every method that manipulates Variable objects must be aware of this distinction.
Constructors
Variable()
Declaration
protected Variable()
Fields
array
The array this variable is an element of, if it is an array element.
Declaration
protected IVariableArray array
Field Value
| Type | Description |
|---|---|
| IVariableArray |
Remarks
null if the variable is not an array element.
attributes
The attributes associated with this variable.
Declaration
protected List<ICompilerAttribute> attributes
Field Value
| Type | Description |
|---|---|
| List<ICompilerAttribute> |
isObserved
Field backing the IsObserved property for base variables. Unused for non-base variables.
Declaration
protected bool isObserved
Field Value
| Type | Description |
|---|---|
| Boolean |
loopRange
Declaration
public Range loopRange
Field Value
| Type | Description |
|---|---|
| Range |
operatorFactorRegistry
Operator to factor registry
Declaration
protected static readonly Dictionary<Variable.Operator, List<Delegate>> operatorFactorRegistry
Field Value
| Type | Description |
|---|---|
| Dictionary<Variable.Operator, List<Delegate>> |
Properties
ArrayVariable
The array that this variable is an element of (otherwise null).
Declaration
public IVariableArray ArrayVariable { get; }
Property Value
| Type | Description |
|---|---|
| IVariableArray |
Remarks
This array may be created implicitly by applying ForEach to a variable. In that case, the variable becomes an element of a fresh array.
Definition
Gets the definition of this variable in the current context. Will return null if the variable is undefined or if it is only defined in a subcontext (such as an If or Switch).
Declaration
public IModelExpression Definition { get; }
Property Value
| Type | Description |
|---|---|
| IModelExpression |
IsArrayElement
Whether this variable is an element of an array
Declaration
public bool IsArrayElement { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
IsDefined
True if the variable is defined in the current condition context.
Declaration
public bool IsDefined { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Remarks
Suppose we have x.SetTo(def) inside [c==0][d==0] Then x.IsDefined is true inside [c==0][d==0], [c==0][d==0][e==0], [c==0], and nothing. x.IsDefined is false inside [c==0][d==1] and [c==1]. In other words, x.IsDefined is true when the current condition context is a prefix of the definition context, or when the definition context is a prefix of the current condition context.
IsLoopIndex
Declaration
public bool IsLoopIndex { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
IsObserved
Is Observed property
Declaration
public bool IsObserved { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
IsReadOnly
Read only property
Declaration
public abstract bool IsReadOnly { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Name
Name
Declaration
public virtual string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
NameInGeneratedCode
Name used in generated code
Declaration
public string NameInGeneratedCode { get; }
Property Value
| Type | Description |
|---|---|
| String |
Methods
AddAttribute(ICompilerAttribute)
Adds an attribute to this variable. Attributes can be used to modify how inference is performed on this variable.
Declaration
public void AddAttribute(ICompilerAttribute attr)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompilerAttribute | attr | The attribute to add |
AddAttribute(QueryType)
Helper to add a query type attribute to this variable.
Declaration
public void AddAttribute(QueryType queryType)
Parameters
| Type | Name | Description |
|---|---|---|
| QueryType | queryType | The query type to use to create the attribute |
AddAttributes(ICompilerAttribute[])
Adds multiple attributes to this variable.
Declaration
public void AddAttributes(params ICompilerAttribute[] attrs)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompilerAttribute[] | attrs | The attributes to add |
AddAttributes(IEnumerable<ICompilerAttribute>)
Adds multiple attributes to this variable.
Declaration
public void AddAttributes(IEnumerable<ICompilerAttribute> attrs)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ICompilerAttribute> | attrs | The attributes to add |
AddDefinitionAttribute(ICompilerAttribute)
Add an attribute to the factor defining this variable.
Declaration
public void AddDefinitionAttribute(ICompilerAttribute attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompilerAttribute | attribute |
AllTrue(Variable<Boolean[]>)
Returns a boolean variable which is true if all array elements are true. For AND of two variables, use the & operator.
Declaration
public static Variable<bool> AllTrue(Variable<bool[]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean[]> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> |
|
AllTrue(Variable<IList<Boolean>>)
Returns a boolean variable which is true if all array elements are true. For AND of two variables, use the & operator.
Declaration
public static Variable<bool> AllTrue(Variable<IList<bool>> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IList<Boolean>> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> |
|
Array<T>(Range)
Creates a 1D random variable array with a specified size.
Declaration
public static VariableArray<T> Array<T>(Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(Range, Range)
Creates a 2D random variable array with specified dimensions.
Declaration
public static VariableArray2D<T> Array<T>(Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r1 | A |
| Range | r2 | A |
Returns
| Type | Description |
|---|---|
| VariableArray2D<T> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(Range, Range, Range)
Creates a 3D random variable array with specified dimensions.
Declaration
public static VariableArray3D<T> Array<T>(Range r1, Range r2, Range r3)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r1 | A |
| Range | r2 | A |
| Range | r3 | A |
Returns
| Type | Description |
|---|---|
| VariableArray3D<T> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(VariableArray<T>, Range)
Creates a 1D random variable array that contains a jagged array of 1D random variables.
Declaration
public static VariableArray<VariableArray<T>, T[][]> Array<T>(VariableArray<T> array, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | A |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(VariableArray<T>, Range, Range)
Creates a 2-D random variable array that contains a jagged array of 1D random variables.
Declaration
public static VariableArray2D<VariableArray<T>, T[][, ]> Array<T>(VariableArray<T> array, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | A |
| Range | r1 | A |
| Range | r2 | A |
Returns
| Type | Description |
|---|---|
| VariableArray2D<VariableArray<T>, T[][,]> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(VariableArray<T>, Range, Range, Range)
Creates a 3-D VariableArray object that contains a jagged array of 1D random variables.
Declaration
public static VariableArray3D<VariableArray<T>, T[][,, ]> Array<T>(VariableArray<T> array, Range r1, Range r2, Range r3)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | A |
| Range | r1 | A |
| Range | r2 | A |
| Range | r3 | A |
Returns
| Type | Description |
|---|---|
| VariableArray3D<VariableArray<T>, T[][,,]> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(VariableArray2D<T>, Range)
Creates a 1D random variable array that contains a jagged array of 2D random variables.
Declaration
public static VariableArray<VariableArray2D<T>, T[, ][]> Array<T>(VariableArray2D<T> array, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray2D<T> | array | A |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray2D<T>, T[,][]> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Array<T>(IList<Range>)
Creates a 1D or 2D random variable array whose dimensions are specified by a list of Range objects.
Declaration
public static IVariableArray Array<T>(IList<Range> ranges)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Range> | ranges | A list of |
Returns
| Type | Description |
|---|---|
| IVariableArray | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Throws |
Array<TItem, TArray>(TItem, Range)
Create a 1D array of random variables
Declaration
public static VariableArray<TItem, TArray> Array<TItem, TArray>(TItem itemPrototype, Range r)
where TItem : Variable, SettableTo<TItem>, ICloneable
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | itemPrototype | A variable object that serves as a prototype for the array elements. |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<TItem, TArray> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| TItem | The variable type of an item. |
| TArray | The domain type of the variable. |
Array<TItem, TArray>(VariableArray<TItem, TArray>, Range)
Create a 1D array of 1D random variable arrays
Declaration
public static VariableArray<VariableArray<TItem, TArray>, TArray[]> Array<TItem, TArray>(VariableArray<TItem, TArray> array, Range r)
where TItem : Variable, SettableTo<TItem>, ICloneable
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, TArray> | array | A variable object that serves as a prototype for the array elements. |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<TItem, TArray>, TArray[]> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| TItem | The variable type of an item after two levels of indexing. |
| TArray | The domain type of an item. |
ArrayFromVector(Variable<Vector>, Range)
Create a random array from values in a Vector.
Declaration
public static VariableArray<double> ArrayFromVector(Variable<Vector> vector, Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | vector | A random vector |
| Range | range | The range to use for indexing the array. Must match the length of the vector. |
Returns
| Type | Description |
|---|---|
| VariableArray<Double> | A new array whose elements are equal to the elements of the vector |
Attrib(ICompilerAttribute)
Inline method for adding an attribute to a variable. This method returns the variable object, so that is can be used in an inline expression. e.g. Variable.GaussianFromMeanAndVariance(0,1).Attrib(new MyAttribute());
Declaration
public Variable Attrib(ICompilerAttribute attr)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompilerAttribute | attr | The attribute to add |
Returns
| Type | Description |
|---|---|
| Variable | The variable object |
Bernoulli(Variable<Double>)
Creates a Boolean random variable with the probability of being true specified by a random variable.
Declaration
public static Variable<bool> Bernoulli(Variable<double> probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | probTrue | A |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> | Returns a Boolean random variable. |
Bernoulli(Double)
Creates a Boolean random variable with a specified probability of being true.
Declaration
public static Variable<bool> Bernoulli(double probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | probTrue | A |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> | Returns a Boolean random variable. |
BernoulliFromLogOdds(Variable<Double>)
Creates a Boolean random variable with the probability of being true specified by the input's logistic function, which is represented by a random variable.
Declaration
public static Variable<bool> BernoulliFromLogOdds(Variable<double> logOdds)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | logOdds | A |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> | Returns a Boolean random variable. |
BernoulliFromLogOdds(Double)
Creates a Boolean random variable with the probability of being true specified by the input's logistic function.
Declaration
public static Variable<bool> BernoulliFromLogOdds(double logOdds)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | logOdds | The input's logistic function, which specifies the probability that the variable is true as probTrue = 1/(1 + exp(-logOdds)). |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> | Returns a Boolean random variable |
BernoulliIntegerSubset(ISparseList<Double>)
Creates a random variable whose domain is a variable-length list of type integer.
Declaration
public static Variable<IList<int>> BernoulliIntegerSubset(ISparseList<double> probInSubset)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | probInSubset | The probability of a given integer being in the random list. This is given as a sparse list - i.e. most of the probabilities are the same. |
Returns
| Type | Description |
|---|---|
| Variable<IList<Int32>> | A BernoulliIntegerSubset distributed random variable |
BernoulliIntegerSubset(Variable<ISparseList<Double>>)
Creates a random variable whose domain is a variable-length list of type integer.
Declaration
public static Variable<IList<int>> BernoulliIntegerSubset(Variable<ISparseList<double>> probInSubset)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<ISparseList<Double>> | probInSubset | The probability of a given integer being in the random list. This is given as random variable over a sparse list - i.e. most of the probabilities are the same. |
Returns
| Type | Description |
|---|---|
| Variable<IList<Int32>> | A BernoulliIntegerSubset distributed random variable |
BernoulliIntegerSubset(VariableArray<Variable<Double>, ISparseList<Double>>)
Creates a random variable whose domain is a variable-length list of type integer.
Declaration
public static Variable<IList<int>> BernoulliIntegerSubset(VariableArray<Variable<double>, ISparseList<double>> probInSubset)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Variable<Double>, ISparseList<Double>> | probInSubset | The probability of a given integer being in the random list. This is given as random variable over a sparse list - i.e. most of the probabilities are the same. |
Returns
| Type | Description |
|---|---|
| Variable<IList<Int32>> | A BernoulliIntegerSubset distributed random variable |
BernoulliList(ISparseList<Double>)
Creates a random variable whose domain is a sparse list of bools.
Declaration
public static VariableArray<Variable<bool>, ISparseList<bool>> BernoulliList(ISparseList<double> probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | probTrue | The sparse list of probTrue elements |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<Boolean>, ISparseList<Boolean>> | A SparseBernoulliList distributed random variable |
BernoulliList(Variable<ISparseList<Double>>)
Creates a random variable whose domain is a sparse list of bools.
Declaration
public static Variable<ISparseList<bool>> BernoulliList(Variable<ISparseList<double>> probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<ISparseList<Double>> | probTrue | The sparse list of probTrue elements |
Returns
| Type | Description |
|---|---|
| Variable<ISparseList<Boolean>> | A SparseBernoulliList distributed random variable |
BernoulliList(VariableArray<Variable<Boolean>, ISparseList<Double>>)
Creates a random variable whose domain is a sparse list of bools.
Declaration
public static VariableArray<Variable<bool>, ISparseList<bool>> BernoulliList(VariableArray<Variable<bool>, ISparseList<double>> probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Variable<Boolean>, ISparseList<Double>> | probTrue | The sparse list of probTrue elements |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<Boolean>, ISparseList<Boolean>> | A SparseBernoulliList distributed random variable |
Beta(Variable<Double>, Variable<Double>)
Creates a Beta-distributed random variable from initial success/failure counts that are represented by random variables.
Declaration
public static Variable<double> Beta(Variable<double> trueCount, Variable<double> falseCount)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | trueCount | A |
| Variable<Double> | falseCount | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Beta-distributed random variable that is statistically defined by Beta(trueCount,falseCount). |
Remarks
The distribution's formula is
prob(x) = (Gamma(trueCount+falseCount)/Gamma(trueCount)/Gamma(falseCount)) x^{trueCount-1} (1-x)^(falseCount-1)
where x is between [0, 1].
Beta(Double, Double)
Creates a Beta-distributed random variable from initial success/failure counts.
Declaration
public static Variable<double> Beta(double trueCount, double falseCount)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | trueCount | The initial success count. |
| Double | falseCount | The initial failure count. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Beta-distributed random variable that is statistically defined by Beta(trueCount,falseCount). |
Remarks
The distribution's formula is
prob(x) = (Gamma(trueCount+falseCount)/Gamma(trueCount)/Gamma(falseCount)) x^{trueCount-1} (1-x)^(falseCount-1)
where x is between [0, 1].
BetaFromMeanAndVariance(Variable<Double>, Variable<Double>)
Creates a Beta-distributed random variable with the mean and variance specified by random variables.
Declaration
public static Variable<double> BetaFromMeanAndVariance(Variable<double> mean, Variable<double> variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | mean | A |
| Variable<Double> | variance | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Beta-distributed random variable whose mean and variance are specified by random variables, |
BetaFromMeanAndVariance(Double, Double)
Creates a Beta-distributed random variable with specified mean and variance
Declaration
public static Variable<double> BetaFromMeanAndVariance(double mean, double variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | mean | The distribution's mean. |
| Double | variance | The distribution's variance. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Beta-distributed random variable whose mean and variance are specified by |
Binomial(Variable<Int32>, Variable<Double>)
Creates a Binomially-distributed random variable with the specified probability of success per trial and number of trials.
Declaration
public static Variable<int> Binomial(Variable<int> trialCount, Variable<double> probSuccess)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | trialCount | A variable containing the number of trials |
| Variable<Double> | probSuccess | A variable containing the probability of success per trial |
Returns
| Type | Description |
|---|---|
| Variable<Int32> |
Binomial(Int32, Variable<Double>)
Creates a Binomially-distributed random variable with the specified probability of success per trial and number of trials.
Declaration
public static Variable<int> Binomial(int trialCount, Variable<double> probSuccess)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | trialCount | The number of trials |
| Variable<Double> | probSuccess | A variable containing the probability of success per trial |
Returns
| Type | Description |
|---|---|
| Variable<Int32> |
Case(Variable<Int32>, Int32)
Opens a stochastic case statement, active when the integer argument has the specified value.
Declaration
public static CaseBlock Case(Variable<int> i, int value)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | i | The condition of the case block |
| Int32 | value | The value of the condition for which the block is active |
Returns
| Type | Description |
|---|---|
| CaseBlock | A CaseBlock object which must be closed before inference is performed. |
Remarks
This method should be used as the argument to a using() statement, so that the if statement is automatically closed. If this is not possible, the returned CaseBlock must be closed manually by calling CloseBlock().
Char(Variable<Vector>)
Creates a character random variable defined by a discrete distribution induced by a given probability vector.
Declaration
public static Variable<char> Char(Variable<Vector> probabilities)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | probabilities | The probability vector. |
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharDigit()
Creates a character random variable from a uniform distribution over digits '0'..'9'.
Declaration
public static Variable<char> CharDigit()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharLetter()
Creates a character random variable from a uniform distribution over letters in 'a'..'z' and 'A'..'Z'.
Declaration
public static Variable<char> CharLetter()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharLetterOrDigit()
Creates a character random variable from a uniform distribution over 'a'..'z', 'A'..'Z' and '0'..'9'.
Declaration
public static Variable<char> CharLetterOrDigit()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharLower()
Creates a character random variable from a uniform distribution over lowercase letters 'a'..'z'.
Declaration
public static Variable<char> CharLower()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharNonWord()
Creates a character random variable from a uniform distribution over all characters except ('a'..'z', 'A'..'Z', '0'..'9', '_' and ''').
Declaration
public static Variable<char> CharNonWord()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharUniform()
Creates a character random variable from a uniform distribution over all possible characters.
Declaration
public static Variable<char> CharUniform()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharUpper()
Creates a character random variable from a uniform distribution over uppercase letters 'A'..'Z'.
Declaration
public static Variable<char> CharUpper()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharWhitespace()
Creates a character random variable from a uniform distribution over whitespace characters ('\t'..'\r', ' ').
Declaration
public static Variable<char> CharWhitespace()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CharWord()
Creates a character random variable from a uniform distribution over word characters ('a'..'z', 'A'..'Z', '0'..'9', '_' and ''').
Declaration
public static Variable<char> CharWord()
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
CloseAllBlocks()
Close blocks in order to recover from exceptions
Declaration
public static void CloseAllBlocks()
Concat(Variable<Vector>, Variable<Vector>)
Creates a random Vector by concatenating two random Vectors.
Declaration
public static Variable<Vector> Concat(Variable<Vector> first, Variable<Vector> second)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | first | First vector |
| Variable<Vector> | second | Second vector |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new vector variable whose value is equal to |
Constant<T>(T)
Defines a constant
Declaration
public static Variable<T> Constant<T>(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value of the constant |
Returns
| Type | Description |
|---|---|
| Variable<T> | The constant object |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the constant |
Constant<T>(T[])
Defines a constant which is a 1D array.
Declaration
public static VariableArray<T> Constant<T>(T[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | value | The constant array |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(T[], Range)
Defines a constant which is a 1D array.
Declaration
public static VariableArray<T> Constant<T>(T[] value, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | value | The constant array |
| Range | r | The range associated with this constant array |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(T[][], Range, Range)
Defines a constant which is a 2-D jagged array
Declaration
public static VariableArray<VariableArray<T>, T[][]> Constant<T>(T[][] value, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| T[][] | value | The constant array |
| Range | r1 | The range associated with the first index |
| Range | r2 | The range associated with the second index |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | A new constant jagged array variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(T[][][], Range, Range, Range)
Defines a constant 3-D jagged array
Declaration
public static VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]> Constant<T>(T[][][] value, Range r1, Range r2, Range r3)
Parameters
| Type | Name | Description |
|---|---|---|
| T[][][] | value | The constant array |
| Range | r1 | The range associated with the first index |
| Range | r2 | The range associated with the second index |
| Range | r3 | The range associated with the third index |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]> | A new constant jagged array variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(T[,])
Defines a constant which is a 2D array.
Declaration
public static VariableArray2D<T> Constant<T>(T[, ] value)
Parameters
| Type | Name | Description |
|---|---|---|
| T[,] | value | The constant array |
Returns
| Type | Description |
|---|---|
| VariableArray2D<T> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(T[,], Range, Range)
Defines a constant which is a 2D array.
Declaration
public static VariableArray2D<T> Constant<T>(T[, ] value, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| T[,] | value | The constant array |
| Range | r1 | The range associated with the first index |
| Range | r2 | The range associated with the second index |
Returns
| Type | Description |
|---|---|
| VariableArray2D<T> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(T[,][], Range, Range, Range)
Defines a constant array of 2-D arrays
Declaration
public static VariableArray<VariableArray2D<T>, T[, ][]> Constant<T>(T[, ][] value, Range r1, Range r2, Range r3)
Parameters
| Type | Name | Description |
|---|---|---|
| T[,][] | value | The constant array |
| Range | r1 | The range associated with the first index |
| Range | r2 | The range associated with the second index |
| Range | r3 | The range associated with the third index |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray2D<T>, T[,][]> | A new constant jagged array variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Constant<T>(IList<T>)
Defines a constant which is a 1D array.
Declaration
public static VariableArray<Variable<T>, IList<T>> Constant<T>(IList<T> value)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<T> | value | The constant list. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IList<T>> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Constant<T>(IList<T>, Range)
Defines a constant which is a 1D array.
Declaration
public static VariableArray<Variable<T>, IList<T>> Constant<T>(IList<T> value, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<T> | value | The constant list. |
| Range | r | The range associated with this constant list. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IList<T>> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Constant<T>(IList<IList<T>>, Range, Range)
Defines a constant which is a 2-D jagged array.
Declaration
public static VariableArray<VariableArray<Variable<T>, IList<T>>, IList<IList<T>>> Constant<T>(IList<IList<T>> value, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<IList<T>> | value | The constant list of lists. |
| Range | r1 | The range associated with the first index. |
| Range | r2 | The range associated with the second index. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<Variable<T>, IList<T>>, IList<IList<T>>> | A new constant jagged array variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Constant<T>(IReadOnlyList<T>)
Defines a constant which is a 1D array.
Declaration
public static VariableArray<Variable<T>, IReadOnlyList<T>> Constant<T>(IReadOnlyList<T> value)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<T> | value | The constant list. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IReadOnlyList<T>> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Constant<T>(IReadOnlyList<T>, Range)
Defines a constant which is a 1D array.
Declaration
public static VariableArray<Variable<T>, IReadOnlyList<T>> Constant<T>(IReadOnlyList<T> value, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<T> | value | The constant list. |
| Range | r | The range associated with this constant list. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IReadOnlyList<T>> | A new constant variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Constant<T>(IReadOnlyList<IReadOnlyList<T>>, Range, Range)
Defines a constant which is a 2-D jagged array.
Declaration
public static VariableArray<VariableArray<Variable<T>, IReadOnlyList<T>>, IReadOnlyList<IReadOnlyList<T>>> Constant<T>(IReadOnlyList<IReadOnlyList<T>> value, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<IReadOnlyList<T>> | value | The constant list of lists. |
| Range | r1 | The range associated with the first index. |
| Range | r2 | The range associated with the second index. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<Variable<T>, IReadOnlyList<T>>, IReadOnlyList<IReadOnlyList<T>>> | A new constant jagged array variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The element type. |
Constrain<T>(Action<T>, Variable<T>)
Applies a constraint using a constraint method with one argument.
Declaration
public static void Constrain<T>(Action<T> constraint, Variable<T> arg1)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T> | constraint | The method that represents the constraint |
| Variable<T> | arg1 | The argument for the constraint |
Type Parameters
| Name | Description |
|---|---|
| T |
Constrain<T1, T2>(Action<T1, T2>, Variable<T1>, Variable<T2>)
Applies a constraint using a constraint method with two arguments.
Declaration
public static void Constrain<T1, T2>(Action<T1, T2> constraint, Variable<T1> arg1, Variable<T2> arg2)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T1, T2> | constraint | The method that represents the constraint |
| Variable<T1> | arg1 | First argument for the constraint |
| Variable<T2> | arg2 | Second argument for the constraint |
Type Parameters
| Name | Description |
|---|---|
| T1 | |
| T2 |
Constrain<T1, T2, T3>(Action<T1, T2, T3>, Variable<T1>, Variable<T2>, Variable<T3>)
Applies a constraint using a constraint method with three arguments.
Declaration
public static void Constrain<T1, T2, T3>(Action<T1, T2, T3> constraint, Variable<T1> arg1, Variable<T2> arg2, Variable<T3> arg3)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T1, T2, T3> | constraint | The method that represents the constraint |
| Variable<T1> | arg1 | First argument for the constraint |
| Variable<T2> | arg2 | Second argument for the constraint |
| Variable<T3> | arg3 | Third argument for the constraint |
Type Parameters
| Name | Description |
|---|---|
| T1 | |
| T2 | |
| T3 |
Constrain<T1, T2, T3, T4>(Action<T1, T2, T3, T4>, Variable<T1>, Variable<T2>, Variable<T3>, Variable<T4>)
Applies a constraint using a constraint method with four arguments.
Declaration
public static void Constrain<T1, T2, T3, T4>(Action<T1, T2, T3, T4> constraint, Variable<T1> arg1, Variable<T2> arg2, Variable<T3> arg3, Variable<T4> arg4)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T1, T2, T3, T4> | constraint | The method that represents the constraint |
| Variable<T1> | arg1 | First argument for the constraint |
| Variable<T2> | arg2 | Second argument for the constraint |
| Variable<T3> | arg3 | Third argument for the constraint |
| Variable<T4> | arg4 | Fourth argument for the constraint |
Type Parameters
| Name | Description |
|---|---|
| T1 | |
| T2 | |
| T3 | |
| T4 |
ConstrainBetween(Variable<Double>, Variable<Double>, Variable<Double>)
Constrains a double variable to be between two limits.
Declaration
public static void ConstrainBetween(Variable<double> x, Variable<double> lowerBound, Variable<double> upperBound)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | x | The variable to constrain |
| Variable<Double> | lowerBound | The lower limit |
| Variable<Double> | upperBound | The upper limit |
ConstrainEqual<T>(T, Variable<T>)
Constrains a variable to equal a constant value.
Declaration
public static void ConstrainEqual<T>(T a, Variable<T> b)
Parameters
| Type | Name | Description |
|---|---|---|
| T | a | The constant value |
| Variable<T> | b | The variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the variable |
ConstrainEqual<T>(Variable<T>, T)
Constrains a variable to equal a constant value.
Declaration
public static void ConstrainEqual<T>(Variable<T> a, T b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | a | The variable |
| T | b | The constant value |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the variable |
ConstrainEqual<T>(Variable<T>, Variable<T>)
Constrains two variables to be equal.
Declaration
public static void ConstrainEqual<T>(Variable<T> a, Variable<T> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | a | The first variable |
| Variable<T> | b | The second variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the variables |
ConstrainEqualRandom<T, TDist>(T, Variable<TDist>)
Constrains a value to be equal to a random sample from a distribution.
Declaration
public static void ConstrainEqualRandom<T, TDist>(T a, Variable<TDist> b)
where TDist : Sampleable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | a | The variable to constrain |
| Variable<TDist> | b | The distribution |
Type Parameters
| Name | Description |
|---|---|
| T | The variable type |
| TDist | The distribution type |
ConstrainEqualRandom<T, TDist>(Variable<T>, TDist)
Constrains a variable to be equal to a random sample from a known distribution.
Declaration
public static void ConstrainEqualRandom<T, TDist>(Variable<T> a, TDist b)
where TDist : Sampleable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | a | The variable to constrain |
| TDist | b | The distribution |
Type Parameters
| Name | Description |
|---|---|
| T | The variable type |
| TDist | The distribution type |
ConstrainEqualRandom<T, TDist>(Variable<T>, Variable<TDist>)
Constrains a variable to be equal to a random sample from a distribution.
Declaration
public static void ConstrainEqualRandom<T, TDist>(Variable<T> a, Variable<TDist> b)
where TDist : Sampleable<T>
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | a | The variable to constrain |
| Variable<TDist> | b | The distribution |
Type Parameters
| Name | Description |
|---|---|
| T | The variable type |
| TDist | The distribution type |
ConstrainFalse(Variable<Boolean>)
Constrains a boolean variable to be false.
Declaration
public static void ConstrainFalse(Variable<bool> v)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean> | v | The variable to constrain to be false |
ConstrainInternal(MethodInfo, Variable[])
Declaration
protected static void ConstrainInternal(MethodInfo methodInfo, params Variable[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| MethodInfo | methodInfo | |
| Variable[] | args |
ConstrainPositive(Variable<Double>)
Constrains a double variable to be positive.
Declaration
public static void ConstrainPositive(Variable<double> v)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | v | The variable to constrain to be positive |
ConstrainTrue(Variable<Boolean>)
Constrains a boolean variable to be true.
Declaration
public static void ConstrainTrue(Variable<bool> v)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean> | v | The variable to constrain to be true |
Copy<T>(Variable<T>)
Returns a copy of the argument
Declaration
public static Variable<T> Copy<T>(Variable<T> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | x | variable to copy. |
Returns
| Type | Description |
|---|---|
| Variable<T> | A new variable that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Copy<T>(VariableArray<T>)
Copy an array
Declaration
public static VariableArray<T> Copy<T>(VariableArray<T> array)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | array to copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | A new array that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of an array element. |
Copy<T>(VariableArray<VariableArray<T>, T[][]>)
Copy an array
Declaration
public static VariableArray<VariableArray<T>, T[][]> Copy<T>(VariableArray<VariableArray<T>, T[][]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<VariableArray<T>, T[][]> | array | array to copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | A new array that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of an array element. |
Copy<TItem, T>(VariableArray<VariableArray<TItem, T>, T[]>)
Copy an array
Declaration
public static VariableArray<VariableArray<TItem, T>, T[]> Copy<TItem, T>(VariableArray<VariableArray<TItem, T>, T[]> array)
where TItem : Variable, ICloneable, SettableTo<TItem>
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<VariableArray<TItem, T>, T[]> | array | array to copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<TItem, T>, T[]> | A new array that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| TItem | The item prototype |
| T | The domain type of an array element. |
CountTrue(Variable<Boolean[]>)
Returns an integer variable equal to the number of array elements that are true.
Declaration
public static Variable<int> CountTrue(Variable<bool[]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean[]> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Int32> |
|
Cut<T>(Variable<T>)
Returns a cut of the argument. Cut is equivalent to random(infer()).
Declaration
public static Variable<T> Cut<T>(Variable<T> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | x | variable to copy. |
Returns
| Type | Description |
|---|---|
| Variable<T> | A new variable that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Remarks
Cut allows forward messages to pass through unchanged, whereas backward messages are cut off.
Cut<T>(VariableArray<T>)
Returns a cut of the argument. Cut is equivalent to random(infer()).
Declaration
public static VariableArray<T> Cut<T>(VariableArray<T> array)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | variable to copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | A new variable that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Remarks
Cut allows forward messages to pass through unchanged, whereas backward messages are cut off.
Cut<T>(VariableArray<VariableArray<T>, T[][]>)
Returns a cut of the argument. Cut is equivalent to random(infer()).
Declaration
public static VariableArray<VariableArray<T>, T[][]> Cut<T>(VariableArray<VariableArray<T>, T[][]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<VariableArray<T>, T[][]> | array | variable to copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | A new variable that is constrained to equal the argument. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Remarks
Cut allows forward messages to pass through unchanged, whereas backward messages are cut off.
CutForwardWhen<T>(Variable<T>, Variable<Boolean>)
Creates a copy of the argument where the forward message is uniform when shouldCut is true. Used to control inference.
Declaration
public static Variable<T> CutForwardWhen<T>(Variable<T> x, Variable<bool> shouldCut)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | x | |
| Variable<Boolean> | shouldCut |
Returns
| Type | Description |
|---|---|
| Variable<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Dirichlet(Vector)
Creates a Dirichlet-distributed random variable with a set of pseudo-counts specified
by a Vector object.
Declaration
public static Variable<Vector> Dirichlet(Vector v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | v | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a Dirichlet-distributed random variable with the pseudo-counts specified
by |
Dirichlet(Range, Vector)
Creates a Dirichlet-distributed random variable with the dimensionality specified by
a Range object and the pseudo-counts specified by a Vector object.
Declaration
public static Variable<Vector> Dirichlet(Range valueRange, Vector v)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Vector | v | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a Dirichlet-distributed random variable with the dimensionality specified by
|
Dirichlet(Range, Variable<Vector>)
Creates a Dirichlet-distributed random variable with the dimensionality specified by
a Range object and the pseudo-counts represented by a random variable.
Declaration
public static Variable<Vector> Dirichlet(Range valueRange, Variable<Vector> v)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Variable<Vector> | v | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a Dirichlet-distributed random variable with the dimensionality specified by
|
Dirichlet(Range, Double[])
Creates a Dirichlet-distributed random variable with the dimensionality specified by
a Range object and a specified set of pseudo-counts.
Declaration
public static Variable<Vector> Dirichlet(Range valueRange, double[] u)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Double[] | u | An array containing the pseudo-counts. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a Dirichlet-distributed random variable of dimension |
Dirichlet(Variable<Vector>)
Creates a Dirichlet-distributed random variable with pseudo-counts specified by a random variable.
Declaration
public static Variable<Vector> Dirichlet(Variable<Vector> pseudoCount)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | pseudoCount | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a Dirichlet-distributed random variable with the pseudo-counts specified
by |
Dirichlet(Double[])
Creates a Dirichlet-distributed random variable with a specified set of pseudo-counts.
Declaration
public static Variable<Vector> Dirichlet(double[] u)
Parameters
| Type | Name | Description |
|---|---|---|
| Double[] | u | An array containing the pseudo-counts. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a Dirichlet-distributed random variable with the pseudo-counts specified
by |
DirichletSymmetric(Range, Variable<Double>)
Creates a symmetric Dirichlet-distributed random variable with the dimension specified by
a Range object and a common pseudo-count, which is represented by a random variable.
Declaration
public static Variable<Vector> DirichletSymmetric(Range valueRange, Variable<double> pseudocount)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Variable<Double> | pseudocount | A pseudo-count, represented by a random variable, which is applied to all dimensions. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a symmetric Dirichlet-distributed random variable with the pseudo-counts
set to |
DirichletSymmetric(Int32, Variable<Double>)
Creates a symmetric Dirichlet-distributed random variable with a specified dimension and a common pseudo-count, which is represented by a random variable.
Declaration
public static Variable<Vector> DirichletSymmetric(int dimension, Variable<double> pseudocount)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dimension | The the Dirichlet distribution's dimensionality. |
| Variable<Double> | pseudocount | A pseudo-count, represented by a random variable, which is applied to all dimensions. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a symmetric Dirichlet-distributed random variable with the pseudo-counts
set to |
DirichletSymmetric(Int32, Double)
Creates a symmetric Dirichlet-distributed random variable with a specified dimension and a common pseudo-count.
Declaration
public static Variable<Vector> DirichletSymmetric(int dimension, double pseudocount)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dimension | The the Dirichlet distribution's dimensionality. |
| Double | pseudocount | A pseudo-count, that is applied to all dimensions. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a symmetric Dirichlet-distributed random variable with the pseudo-counts
set to |
DirichletUniform(Range)
Creates a uniform Dirichlet-distributed random variable with dimension specified by a
Range object.
Declaration
public static Variable<Vector> DirichletUniform(Range valueRange)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a uniform Dirichlet-distributed random variable. The distribution's pseudo-counts are all set to 1. |
DirichletUniform(Variable<Int32>)
Create a uniform Dirichlet-distributed random variable with a specified dimension.
Declaration
public static Variable<Vector> DirichletUniform(Variable<int> dimension)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | dimension | The the Dirichlet distribution's dimensionality. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a uniform Dirichlet-distributed random variable. The distribution's pseudo-counts are all 1. |
DirichletUniform(Int32)
Create a uniform Dirichlet-distributed random variable with a specified dimension.
Declaration
public static Variable<Vector> DirichletUniform(int dimension)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dimension | The the Dirichlet distribution's dimensionality. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a uniform Dirichlet-distributed random variable. The distribution's pseudo-counts are all 1. |
Discrete(Vector)
Creates a random variable that is statistically defined by a Discrete distribution with the set of possible
values specified by a Vector object.
Declaration
public static Variable<int> Discrete(Vector v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | v | A |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Discrete(Range, Vector)
Creates a random variable that is statistically defined by a Discrete distribution with the number of possible
values specified by a Range object and the probabilities by a Vector object.
Declaration
public static Variable<int> Discrete(Range valueRange, Vector v)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Vector | v | A |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Discrete(Range, Variable<Vector>)
Creates a random variable that is statistically defined by a Discrete distribution with the number of
possible values specified by a Range object and the probabilities of
the possible values specified by an Vector random variable.
Declaration
public static Variable<int> Discrete(Range valueRange, Variable<Vector> probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A range defining the possible values for the variable. |
| Variable<Vector> | probs | A variable holding the set of probabilities of having each value. Must add up to one. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Discrete(Range, Double[])
Creates a random variable that is statistically defined by a Discrete distribution with a specified number of possible values, and a corresponding set of probabilities.
Declaration
public static Variable<int> Discrete(Range valueRange, params double[] probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Double[] | probs | An array that specifies the probability of each possible value, from [0, probs.Length-1]. The array must have more than one element. The probabilities should sum to 1.0. If not, the probabilities will be normalized. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
Discrete(Variable<Vector>)
Creates a random variable that is statistically defined by a Discrete distribution with the probabilities of
the possible values specified by an Vector random variable.
Declaration
public static Variable<int> Discrete(Variable<Vector> probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | probs | A |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Discrete(Double[])
Creates a random variable that is statistically defined by a Discrete distribution with a specified set of probabilities.
Declaration
public static Variable<int> Discrete(params double[] probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Double[] | probs | An array that specifies the probability of each possible value, from [0, probs.Length-1]. The array must have more than one element. The probabilities should sum to 1.0. If not, the probabilities will be normalized. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
DiscreteFromLogProbs(VariableArray<Double>)
Creates a random int variable x where p(x=k) is proportional to exp(logProbs[k]), i.e. the softmax function of the logProbs.
Declaration
public static Variable<int> DiscreteFromLogProbs(VariableArray<double> logProbs)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Double> | logProbs | Arguments to the softmax. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | An integer random variable |
DiscreteUniform(Range)
Create a random integer by drawing uniformly from a range.
Declaration
public static Variable<int> DiscreteUniform(Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | range | A |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | A random integer with an equal probability of taking any value in the range. |
DiscreteUniform(Range, Variable<Int32>)
Creates a random variable that is statistically defined by a uniform Discrete distribution with the number
of possible values specified by Range object, and the upper bound specified by a random variable.
Declaration
public static Variable<int> DiscreteUniform(Range valueRange, Variable<int> size)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Variable<Int32> | size | A random variable that represents the dimension of the discrete distribution. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by a Discrete distribution with equal probabilities for each possible value. |
DiscreteUniform(Variable<Int32>)
Creates a random variable that is statistically defined by a Discrete distribution with the number
of possible values specified by an int random variable.
Declaration
public static Variable<int> DiscreteUniform(Variable<int> size)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | size | An |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | Returns a random variable that is statistically defined by a Discrete distribution with equal probabilities for each possible value. |
DiscreteUniform(Int32)
Create a random integer by drawing uniformly from the range 0..(size-1)
Declaration
public static Variable<int> DiscreteUniform(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The number of possible values. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | A random variable with an equal probability of taking any value in the range 0..(size-1) |
Double(IModelExpression<Int32>)
Create a double-precision random variable that is constrained to equal the given integer expression.
Declaration
public static Variable<double> Double(IModelExpression<int> integer)
Parameters
| Type | Name | Description |
|---|---|---|
| IModelExpression<Int32> | integer | An integer expression |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
Double(Variable<Boolean>)
Creates a double-precision random variable that is constrained to equal 1.0 when the given boolean is true, otherwise 0.0.
Declaration
public static Variable<double> Double(Variable<bool> boolean)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean> | boolean | A boolean variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
Double(Variable<Int32>)
Create a double-precision random variable that is constrained to equal the given integer variable.
Declaration
public static Variable<double> Double(Variable<int> integer)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | integer | An integer variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
EnumDiscrete<TEnum>(Vector)
Creates a random variable with a Discrete distribution with the probabilities for each of
the values of the enum type specified by a Vector object.
Declaration
public static Variable<TEnum> EnumDiscrete<TEnum>(Vector probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | probs | A |
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type. |
EnumDiscrete<TEnum>(Range, Vector)
Creates a random variable with a Discrete distribution with the number of possible values
specified by a Range object and the probabilities for each of
the values of the enum type specified by a Vector object.
Declaration
public static Variable<TEnum> EnumDiscrete<TEnum>(Range valueRange, Vector probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Vector | probs | The vector of probabilities of having each value. Must add up to one. |
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enum |
EnumDiscrete<TEnum>(Range, Double[])
Creates a random variable with a Discrete distribution with the dimension specified by a Range
object and specified probabilities for each of the values of the enum type.
Declaration
public static Variable<TEnum> EnumDiscrete<TEnum>(Range valueRange, params double[] probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A |
| Double[] | probs | A |
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type. |
EnumDiscrete<TEnum>(Variable<Vector>)
Creates a random variable with a Discrete distribution using probabilities specified by a Vector
object for each of the values of the specified enum type.
Declaration
public static Variable<TEnum> EnumDiscrete<TEnum>(Variable<Vector> probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | probs | A |
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type. |
EnumDiscrete<TEnum>(Double[])
Creates a random variable with a Discrete distribution with specified probabilities for each of the values of the specified enum type.
Declaration
public static Variable<TEnum> EnumDiscrete<TEnum>(params double[] probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Double[] | probs | A |
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Returns a random variable that is statistically defined by the specified Discrete distribution. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type. |
EnumToInt<TEnum>(Variable<TEnum>)
Creates a random int variable corresponding to a random enum variable. The returned variable can be used as the condition for a Switch or Case block.
Declaration
public static Variable<int> EnumToInt<TEnum>(Variable<TEnum> enumVar)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<TEnum> | enumVar | The enum variable |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | An integer random variable |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type |
EnumUniform<TEnum>()
Creates a random variable with a Discrete distribution with a uniform distribution.
Declaration
public static Variable<TEnum> EnumUniform<TEnum>()
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Returns a random variable that is statistically defined by the a Discrete distribution with equal probabilities for all possible values. |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type. |
EnumUniform<TEnum>(Range)
Creates a random variable with a Discrete distribution with the dimension specified by a Range
object and a uniform distribution.
Declaration
public static Variable<TEnum> EnumUniform<TEnum>(Range valueRange)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A range over the enum values. |
Returns
| Type | Description |
|---|---|
| Variable<TEnum> | Enum random variable |
Type Parameters
| Name | Description |
|---|---|
| TEnum | The type of the enum |
Exp(Variable<Double>)
Returns a variable which takes e to the power of another random variable
Declaration
public static Variable<double> Exp(Variable<double> exponent)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | exponent | The specified exponent |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
ForEach(Range)
Creates a new 'for each' block
Declaration
public static ForEachBlock ForEach(Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | range |
Returns
| Type | Description |
|---|---|
| ForEachBlock |
FunctionEvaluate(Variable<IFunction>, Variable<Vector>)
Evaluate a random function at a point
Declaration
public static Variable<double> FunctionEvaluate(Variable<IFunction> func, Variable<Vector> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IFunction> | func | A random function |
| Variable<Vector> | x | The location to evaluate the function |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable equal to |
GammaFromMeanAndVariance(Variable<Double>, Variable<Double>)
Creates a Gamma-distributed random variable with its mean and variance parameters represented by random variables.
Declaration
public static Variable<double> GammaFromMeanAndVariance(Variable<double> mean, Variable<double> variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | mean | A |
| Variable<Double> | variance | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gamma-distributed random variable with the specified mean and variance parameters. |
GammaFromMeanAndVariance(Double, Double)
Creates a Gamma-distributed random variable with specified mean and variance parameters.
Declaration
public static Variable<double> GammaFromMeanAndVariance(double mean, double variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | mean | The mean parameter value. |
| Double | variance | The variance parameter value. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gamma-distributed random variable with the specified mean and variance parameters. |
GammaFromShapeAndRate(Variable<Double>, Variable<Double>)
Creates a Gamma-distributed random variable with its shape and rate parameters represented by random variables.
Declaration
public static Variable<double> GammaFromShapeAndRate(Variable<double> shape, Variable<double> rate)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | shape | A |
| Variable<Double> | rate | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gamma-distributed random variable with the specified shape and rate parameters. |
GammaFromShapeAndRate(Double, Double)
Creates a Gamma-distributed random variable with specified shape and rate parameters.
Declaration
public static Variable<double> GammaFromShapeAndRate(double shape, double rate)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | shape | The shape parametervalue. |
| Double | rate | The rate parameter value. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gamma-distributed random variable with the specified shape and rate parameters. |
GammaFromShapeAndScale(Variable<Double>, Variable<Double>)
Creates a Gamma-distributed random variable with its shape and scale parameters represented by random variables.
Declaration
public static Variable<double> GammaFromShapeAndScale(Variable<double> shape, Variable<double> scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | shape | A |
| Variable<Double> | scale | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gamma-distributed random variable with the specified shape and scale parameters. |
GammaFromShapeAndScale(Double, Double)
Creates a Gamma-distributed random variable with specified shape and scale parameters.
Declaration
public static Variable<double> GammaFromShapeAndScale(double shape, double scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | shape | The shape parameter value. |
| Double | scale | The scale parameter value. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gamma-distributed random variable with the specified shape and scale parameters. |
GaussianFromMeanAndPrecision(Variable<Double>, Variable<Double>)
Creates a Gaussian-distributed random variable with mean and precision represented by random variables.
Declaration
public static Variable<double> GaussianFromMeanAndPrecision(Variable<double> mean, Variable<double> precision)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | mean | A |
| Variable<Double> | precision | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gaussian-distributed random variable with the specified mean and precision. |
Remarks
The variance is 1/precision.
GaussianFromMeanAndPrecision(Double, Double)
Creates a Gaussian-distributed random variable with specified mean and precision.
Declaration
public static Variable<double> GaussianFromMeanAndPrecision(double mean, double precision)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | mean | The mean. |
| Double | precision | The precision. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gaussian-distributed random variable with the specified mean and precision. |
Remarks
The variance is 1/precision.
GaussianFromMeanAndVariance(Variable<Double>, Variable<Double>)
Creates a Gaussian-distributed random variable with the mean and variance represented by random variables.
Declaration
public static Variable<double> GaussianFromMeanAndVariance(Variable<double> mean, Variable<double> variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | mean | A |
| Variable<Double> | variance | A |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gaussian-distributed random variable with the specified mean and variance. |
GaussianFromMeanAndVariance(Variable<Double>, Double)
Creates a Gaussian-distributed random variable with a specified variance, and the mean represented by a random variable.
Declaration
public static Variable<double> GaussianFromMeanAndVariance(Variable<double> mean, double variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | mean | An |
| Double | variance | The variance. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gaussian-distributed random variable with the specified mean and variance. |
GaussianFromMeanAndVariance(Double, Double)
Creates a Gaussian-distributed random variable with specified mean and variance.
Declaration
public static Variable<double> GaussianFromMeanAndVariance(double mean, double variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | mean | The mean. |
| Double | variance | The variance. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a Gaussian-distributed random variable with the specified mean and variance. |
GaussianListFromMeanAndPrecision(ISparseList<Double>, ISparseList<Double>)
Returns a random variable over a sparse vector domain where each element is statistically defined in terms of the corresponding mean and precision elements in sparse vectors of means and precisions
Declaration
public static Variable<ISparseList<double>> GaussianListFromMeanAndPrecision(ISparseList<double> mean, ISparseList<double> precision)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | mean | The sparse list of means |
| ISparseList<Double> | precision | The sparse list of precisions |
Returns
| Type | Description |
|---|---|
| Variable<ISparseList<Double>> | A SparseGaussianList distributed random variable |
GaussianListFromMeanAndPrecision(ISparseList<Double>, Variable<ISparseList<Double>>)
Returns a random variable over a sparse list domain where each element is statistically defined in terms of the corresponding mean and precision elements in sparse vectors of means and precisions
Declaration
public static Variable<ISparseList<double>> GaussianListFromMeanAndPrecision(ISparseList<double> mean, Variable<ISparseList<double>> precision)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | mean | The sparse list of means |
| Variable<ISparseList<Double>> | precision | The sparse list of precisions variable |
Returns
| Type | Description |
|---|---|
| Variable<ISparseList<Double>> | A SparseGaussianList distributed random variable |
GaussianListFromMeanAndPrecision(Variable<ISparseList<Double>>, ISparseList<Double>)
Returns a random variable over a sparse vector domain where each element is statistically defined in terms of the corresponding mean and precision elements in sparse vectors of means and precisions
Declaration
public static Variable<ISparseList<double>> GaussianListFromMeanAndPrecision(Variable<ISparseList<double>> mean, ISparseList<double> precision)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<ISparseList<Double>> | mean | The sparse list of means variable |
| ISparseList<Double> | precision | The sparse list of precisions |
Returns
| Type | Description |
|---|---|
| Variable<ISparseList<Double>> | A SparseGaussianList distributed random variable |
GaussianListFromMeanAndPrecision(Variable<ISparseList<Double>>, Variable<ISparseList<Double>>)
Returns a random variable over a sparse list domain where each element is statistically defined in terms of the corresponding mean and precision elements in sparse vectors of means and precisions
Declaration
public static Variable<ISparseList<double>> GaussianListFromMeanAndPrecision(Variable<ISparseList<double>> mean, Variable<ISparseList<double>> precision)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<ISparseList<Double>> | mean | The sparse list of means variable |
| Variable<ISparseList<Double>> | precision | The sparse list of precisions variable |
Returns
| Type | Description |
|---|---|
| Variable<ISparseList<Double>> | A SparseGaussianList distributed random variable |
GetAttributes<AttributeType>()
Get all attributes of this variable having type AttributeType.
Declaration
public IEnumerable<AttributeType> GetAttributes<AttributeType>()
where AttributeType : ICompilerAttribute
Returns
| Type | Description |
|---|---|
| IEnumerable<AttributeType> |
Type Parameters
| Name | Description |
|---|---|
| AttributeType |
GetContainers<T>()
List of containers for this variable (ForEachBlock, IfBlock, etc.)
Declaration
public List<T> GetContainers<T>()
Returns
| Type | Description |
|---|---|
| List<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
GetDomainType()
Gets the domain type of a Variable<T>
Declaration
public Type GetDomainType()
Returns
| Type | Description |
|---|---|
| Type | The type parameter T of Variable<T> |
Remarks
this must be a Variable<T>
GetExpression()
Gets a syntax tree which refers to this variable in MSL.
Declaration
public IExpression GetExpression()
Returns
| Type | Description |
|---|---|
| IExpression |
GetFirstAttribute<AttributeType>()
Gets the first attribute of the specified type
Declaration
public AttributeType GetFirstAttribute<AttributeType>()
where AttributeType : ICompilerAttribute
Returns
| Type | Description |
|---|---|
| AttributeType | The first attribute of the specified type |
Type Parameters
| Name | Description |
|---|---|
| AttributeType | The type of attribute to look for |
GetItem(Variable<Vector>, Variable<Int32>)
Copy an element of a vector.
Declaration
public static Variable<double> GetItem(Variable<Vector> source, Variable<int> index)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | source | Random vector. |
| Variable<Int32> | index | Index of the element to copy. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new double variable equal to |
GetItem(Variable<String>, Variable<Int32>)
Creates a character random variable representing the character on a given position inside a given string.
Declaration
public static Variable<char> GetItem(Variable<string> str, Variable<int> position)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<String> | str | The string. |
| Variable<Int32> | position | The character position. |
Returns
| Type | Description |
|---|---|
| Variable<Char> | The created random variable. |
GetItemExpression()
Helper function for implementing GetExpression.
Declaration
protected IExpression GetItemExpression()
Returns
| Type | Description |
|---|---|
| IExpression |
GetItems<T>(Variable<T[]>, VariableArray<Int32>)
Gets a variable array containing (possibly duplicated) items of a source array
Declaration
public static VariableArray<T> GetItems<T>(Variable<T[]> array, VariableArray<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T[]> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. Indices may be duplicated. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements |
Remarks
If the indices are known to be all different, use Subarray<T>(Variable<T[]>, VariableArray<Int32>) for greater efficiency.
GetItems<T>(Variable<IReadOnlyList<T>>, VariableArray<Int32>)
Gets a variable array containing (possibly duplicated) items of a source array
Declaration
public static VariableArray<T> GetItems<T>(Variable<IReadOnlyList<T>> array, VariableArray<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IReadOnlyList<T>> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. Indices may be duplicated. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements |
Remarks
If the indices are known to be all different, use Subarray<T>(Variable<T[]>, VariableArray<Int32>) for greater efficiency.
GetItems<T>(VariableArray<T>, VariableArray<Int32>)
Gets a variable array containing (possibly duplicated) items of a source array
Declaration
public static VariableArray<T> GetItems<T>(VariableArray<T> array, VariableArray<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. Indices may be duplicated. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements |
Remarks
If the indices are known to be all different, use Subarray<T>(Variable<T[]>, VariableArray<Int32>) for greater efficiency.
GetItems<TItem, T>(VariableArray<TItem, T[]>, VariableArray<Int32>)
Gets a variable array containing (possibly duplicated) items of a source array
Declaration
public static VariableArray<TItem, T[]> GetItems<TItem, T>(VariableArray<TItem, T[]> array, VariableArray<int> indices)
where TItem : Variable, ICloneable, SettableTo<TItem>
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, T[]> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. Indices may be duplicated. |
Returns
| Type | Description |
|---|---|
| VariableArray<TItem, T[]> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| TItem | The inner variable type |
| T | The domain type of array elements |
Remarks
If the indices are known to be all different, use Subarray<T>(Variable<T[]>, VariableArray<Int32>) for greater efficiency.
GetValueRange()
Get the ValueRange attribute of this variable, if any has been set, otherwise throws an exception.
Declaration
public Range GetValueRange()
Returns
| Type | Description |
|---|---|
| Range |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the variable has no ValueRange attribute. |
GetValueRange(Boolean)
Get the ValueRange attribute of this variable, if any has been set.
Declaration
public Range GetValueRange(bool throwIfMissing)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | throwIfMissing | Indicates if a missing attribute should throw an exception. |
Returns
| Type | Description |
|---|---|
| Range |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the variable has no ValueRange attribute and |
HasAnyItemDefined(IReadOnlyList<ConditionBlock>)
True if the variable (or any item of it) is defined in the given context.
Declaration
protected bool HasAnyItemDefined(IReadOnlyList<ConditionBlock> currentConditions)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<ConditionBlock> | currentConditions |
Returns
| Type | Description |
|---|---|
| Boolean |
HasAttribute<AttributeType>()
Determines if this variable has at least one attribute of type AttributeType.
Declaration
public bool HasAttribute<AttributeType>()
where AttributeType : ICompilerAttribute
Returns
| Type | Description |
|---|---|
| Boolean | True if the variable has one or more attribute of that type, false otherwise |
Type Parameters
| Name | Description |
|---|---|
| AttributeType | The type of attribute to look for |
HasDefinedItem(IReadOnlyList<ConditionBlock>, List<List<IModelExpression>>, Int32)
Declaration
protected bool HasDefinedItem(IReadOnlyList<ConditionBlock> currentConditions, List<List<IModelExpression>> indices, int depth)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<ConditionBlock> | currentConditions | |
| List<List<IModelExpression>> | indices | |
| Int32 | depth |
Returns
| Type | Description |
|---|---|
| Boolean |
IArray<T>(Range)
Creates a 1D random variable IArray with a specified size.
Declaration
public static VariableArray<Variable<T>, IArray<T>> IArray<T>(Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IArray<T>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IArray<T>(Range, Range)
Creates a 2D random variable array with specified dimensions.
Declaration
public static VariableArray2D<Variable<T>, IArray2D<T>> IArray<T>(Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r1 | A |
| Range | r2 | A |
Returns
| Type | Description |
|---|---|
| VariableArray2D<Variable<T>, IArray2D<T>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IArray<T>(VariableArray<T>, Range)
Creates a 1D random variable IArray that contains a jagged array of 1D random variables.
Declaration
public static VariableArray<VariableArray<T>, IArray<T[]>> IArray<T>(VariableArray<T> array, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | A |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, IArray<T[]>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IArray<T>(VariableArray<T>, Range, Range)
Create a 2-D random variable IArray2D that contains a jagged array of 1D random variables.
Declaration
public static VariableArray2D<VariableArray<T>, IArray2D<T[]>> IArray<T>(VariableArray<T> array, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | A |
| Range | r1 | A |
| Range | r2 | A |
Returns
| Type | Description |
|---|---|
| VariableArray2D<VariableArray<T>, IArray2D<T[]>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IArray<T>(VariableArray2D<T>, Range)
Creates a 1D random variable IArray that contains a jagged array of 2D random variables.
Declaration
public static VariableArray<VariableArray2D<T>, IArray<T[, ]>> IArray<T>(VariableArray2D<T> array, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray2D<T> | array | A |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray2D<T>, IArray<T[,]>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IArray<TItem, TArray>(VariableArray<TItem, TArray>, Range)
Create a 1D IArray of 1D random variable arrays
Declaration
public static VariableArray<VariableArray<TItem, TArray>, IArray<TArray>> IArray<TItem, TArray>(VariableArray<TItem, TArray> array, Range r)
where TItem : Variable, SettableTo<TItem>, ICloneable
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, TArray> | array | A variable object that serves as a prototype for the array elements. |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<TItem, TArray>, IArray<TArray>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| TItem | The variable type of an item after two levels of indexing. |
| TArray | The domain type of an item. |
If(Variable<Boolean>)
Opens a stochastic if statement, active when the argument is true.
Declaration
public static IfBlock If(Variable<bool> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean> | b | The condition of the if block |
Returns
| Type | Description |
|---|---|
| IfBlock | An IfBlock object which must be closed before inference is performed. |
Remarks
This method should be used as the argument to a using() statement, so that the if statement is automatically closed. If this is not possible, the returned IfBlock must be closed manually by calling CloseBlock().
IfNot(Variable<Boolean>)
Opens a stochastic if statement, active when the argument is false.
Declaration
public static IfBlock IfNot(Variable<bool> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean> | b | The condition of the if block |
Returns
| Type | Description |
|---|---|
| IfBlock | An IfBlock object which must be closed before inference is performed. |
Remarks
This method should be used as the argument to a using() statement, so that the if statement is automatically closed. If this is not possible, the returned IfBlock must be closed manually by calling CloseBlock().
IList<T>(Range)
Creates a 1D random variable IList with a specified size.
Declaration
public static VariableArray<Variable<T>, IList<T>> IList<T>(Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IList<T>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IList<T>(VariableArray<T>, Range)
Creates a 1D random variable IList that contains a jagged array of 1D random variables.
Declaration
public static VariableArray<VariableArray<T>, IList<T[]>> IList<T>(VariableArray<T> array, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | A |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, IList<T[]>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IList<TItem, TArray>(VariableArray<TItem, TArray>, Range)
Create a 1D IList of 1D random variable arrays
Declaration
public static VariableArray<VariableArray<TItem, TArray>, IList<TArray>> IList<TItem, TArray>(VariableArray<TItem, TArray> array, Range r)
where TItem : Variable, SettableTo<TItem>, ICloneable
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, TArray> | array | A variable object that serves as a prototype for the array elements. |
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<TItem, TArray>, IList<TArray>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| TItem | The variable type of an item after two levels of indexing. |
| TArray | The domain type of an item. |
InnerProduct(Variable<DenseVector>, Variable<Vector>)
Returns a double random variable which is the inner product of two vector variables.
Declaration
public static Variable<double> InnerProduct(Variable<DenseVector> a, Variable<Vector> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<DenseVector> | a | The first vector variable |
| Variable<Vector> | b | The second vector variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
InnerProduct(Variable<Vector>, Variable<DenseVector>)
Returns a double random variable which is the inner product of two vector variables.
Declaration
public static Variable<double> InnerProduct(Variable<Vector> a, Variable<DenseVector> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | a | The first vector variable |
| Variable<DenseVector> | b | The second vector variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
InnerProduct(Variable<Vector>, Variable<Vector>)
Returns a double random variable which is the inner product of two vector variables.
Declaration
public static Variable<double> InnerProduct(Variable<Vector> a, Variable<Vector> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | a | The first vector variable |
| Variable<Vector> | b | The second vector variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
InnerProduct(VariableArray<Double>, Variable<Vector>)
Returns a double random variable which is the inner product of an array and a vector variable.
Declaration
public static Variable<double> InnerProduct(VariableArray<double> a, Variable<Vector> b)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Double> | a | The array variable |
| Variable<Vector> | b | The vector variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
InnerProduct(VariableArray<Double>, VariableArray<Double>)
Returns a double random variable which is the inner product of two array variables.
Declaration
public static Variable<double> InnerProduct(VariableArray<double> a, VariableArray<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Double> | a | The first array variable |
| VariableArray<Double> | b | The second array variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
IsBetween(Variable<Double>, Variable<Double>, Variable<Double>)
Returns a boolean random variable indicating if the supplied double random variable is between the specified limits.
Declaration
public static Variable<bool> IsBetween(Variable<double> x, Variable<double> lowerBound, Variable<double> upperBound)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | x | The double variable to test |
| Variable<Double> | lowerBound | The lower limit |
| Variable<Double> | upperBound | The upper limit |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> | True if (lowerBound <= x) and (x < upperBound) |
IsConstantScalar(IModelExpression)
Declaration
protected bool IsConstantScalar(IModelExpression expr)
Parameters
| Type | Name | Description |
|---|---|---|
| IModelExpression | expr |
Returns
| Type | Description |
|---|---|
| Boolean |
IsDefinedInContext(List<ConditionBlock>)
True if the variable is defined in the given condition context.
Declaration
public bool IsDefinedInContext(List<ConditionBlock> context)
Parameters
| Type | Name | Description |
|---|---|---|
| List<ConditionBlock> | context |
Returns
| Type | Description |
|---|---|
| Boolean |
Remarks
Suppose we have x.SetTo(def) inside [c==0][d==0] Then x.IsDefinedInContext is true inside [c==0][d==0], [c==0][d==0][e==0], [c==0], and nothing. x.IsDefinedInContext is false inside [c==0][d==1] and [c==1]. In other words, IsDefinedInContext is true when the context is a prefix of the definition context, or when the definition context is a prefix of the context.
ISparseList<T>(Range)
Creates a 1D random variable ISparseList with a specified size.
Declaration
public static VariableArray<Variable<T>, ISparseList<T>> ISparseList<T>(Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | r | A |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, ISparseList<T>> | Returns a |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
IsPositive(Variable<Double>)
Returns a boolean random variable indicating if the supplied double random variable is positive.
Declaration
public static Variable<bool> IsPositive(Variable<double> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | x | The random variable to test for positivity |
Returns
| Type | Description |
|---|---|
| Variable<Boolean> | True if (x > 0) |
IsPrefixOf<T>(IReadOnlyList<T>, IReadOnlyList<T>)
True if prefix is a prefix of list.
Declaration
protected static bool IsPrefixOf<T>(IReadOnlyList<T> prefix, IReadOnlyList<T> list)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<T> | prefix | |
| IReadOnlyList<T> | list |
Returns
| Type | Description |
|---|---|
| Boolean |
Type Parameters
| Name | Description |
|---|---|
| T |
JaggedSubarray<T>(VariableArray<T>, VariableArray<VariableArray<Int32>, Int32[][]>)
Gets a jagged variable array containing items of a source list.
Declaration
public static VariableArray<VariableArray<T>, T[][]> JaggedSubarray<T>(VariableArray<T> array, VariableArray<VariableArray<int>, int[][]> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array. |
| VariableArray<VariableArray<Int32>, Int32[][]> | indices | Variable array containing the indices of the elements to get. indices[i][j] must be different for different j and same i, but can match for different i. The shape of this array determines the shape of the result. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | A jagged variable array with the specified items. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
If all indices are different, use SplitSubarray<T>(VariableArray<T>, VariableArray<VariableArray<Int32>, Int32[][]>). To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Linear(Variable<Int32>, Variable<Int32>, Variable<Double>)
Adds a linear factor between two int variables (max product only!).
Declaration
public static void Linear(Variable<int> a, Variable<int> b, Variable<double> logUnitCost)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | a | The first int variable |
| Variable<Int32> | b | The second int variable |
| Variable<Double> | logUnitCost | The negative log cost per unit absolute different between the variables |
Remarks
This factor has the value of exp( -|a-b|* logUnitCost ).
LinearTrunc(Variable<Int32>, Variable<Int32>, Variable<Double>, Variable<Double>)
Adds a truncated linear factor between two int variables (max product only!).
Declaration
public static void LinearTrunc(Variable<int> a, Variable<int> b, Variable<double> logUnitCost, Variable<double> maxCost)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | a | The first int variable |
| Variable<Int32> | b | The second int variable |
| Variable<Double> | logUnitCost | The negative log cost per unit absolute different between the variables |
| Variable<Double> | maxCost | The maximum negative log cost |
Remarks
This factor has the value of exp( - min( |a-b|* logUnitCost, maxCost) )).
Log(Variable<Double>)
Returns a variable equal to the natural logarithm of d
Declaration
public static Variable<double> Log(Variable<double> d)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | d | The variable argument |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
Logistic(Variable<Double>)
Creates a variable equal to 1/(1+exp(-x))
Declaration
public static Variable<double> Logistic(Variable<double> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | x | The variable argument |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
LookupOperatorFactor(Variable.Operator, Type[])
Retrieves the factor method for a given operator and parameter types.
Declaration
public static Delegate LookupOperatorFactor(Variable.Operator op, params Type[] parameterTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable.Operator | op | The operator. |
| Type[] | parameterTypes | The types of the parameters. |
Returns
| Type | Description |
|---|---|
| Delegate | The retrieved factor method, or null if no suitable method found. |
Matrix(Variable<Double[,]>)
Create a random Matrix from values in an array.
Declaration
public static Variable<Matrix> Matrix(Variable<double[, ]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double[,]> | array | A random array |
Returns
| Type | Description |
|---|---|
| Variable<Matrix> | A new matrix variable whose value is equal to |
MatrixMultiply(VariableArray2D<Double>, VariableArray2D<Double>)
Returns a 2-D array of variables which is the matrix product of two other 2-D arrays of variables
Declaration
public static VariableArray2D<double> MatrixMultiply(VariableArray2D<double> a, VariableArray2D<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray2D<Double> | a | The first 2-D array |
| VariableArray2D<Double> | b | The second 2-D array |
Returns
| Type | Description |
|---|---|
| VariableArray2D<Double> |
MatrixTimesScalar(Variable<PositiveDefiniteMatrix>, Variable<Double>)
Create a matrix variable whose [i,j] entry equals a[i,j]*b
Declaration
public static Variable<PositiveDefiniteMatrix> MatrixTimesScalar(Variable<PositiveDefiniteMatrix> a, Variable<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<PositiveDefiniteMatrix> | a | The matrix |
| Variable<Double> | b | The scalar |
Returns
| Type | Description |
|---|---|
| Variable<PositiveDefiniteMatrix> |
MatrixTimesVector(Variable<Matrix>, Variable<Vector>)
Returns a Vector variable which is the product of a Matrix variable with a Vector variable
Declaration
public static Variable<Vector> MatrixTimesVector(Variable<Matrix> matrix, Variable<Vector> vector)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Matrix> | matrix | The matrix |
| Variable<Vector> | vector | The vector |
Returns
| Type | Description |
|---|---|
| Variable<Vector> |
MatrixTimesVector(Variable<Double[,]>, Variable<Vector>)
Returns a Vector variable which is the product of a two-dimensional array variable (treated as a Matrix) with a Vector variable
Declaration
public static Variable<Vector> MatrixTimesVector(Variable<double[, ]> array, Variable<Vector> vector)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double[,]> | array | The matrix |
| Variable<Vector> | vector | The vector |
Returns
| Type | Description |
|---|---|
| Variable<Vector> |
Max(Variable<Double>, Variable<Double>)
Returns a double variable which is the max of two double variables
Declaration
public static Variable<double> Max(Variable<double> a, Variable<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | a | The first variable |
| Variable<Double> | b | The second variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
Max(Variable<Int32>, Variable<Int32>)
Returns an int variable which is the maximum of two int variables
Declaration
public static Variable<int> Max(Variable<int> a, Variable<int> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | a | The first variable |
| Variable<Int32> | b | The second variable |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | A new variable |
MayOverlap(IReadOnlyList<IModelExpression>, IReadOnlyList<IModelExpression>)
Declaration
protected bool MayOverlap(IReadOnlyList<IModelExpression> list1, IReadOnlyList<IModelExpression> list2)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<IModelExpression> | list1 | |
| IReadOnlyList<IModelExpression> | list2 |
Returns
| Type | Description |
|---|---|
| Boolean |
Min(Variable<Double>, Variable<Double>)
Returns a double variable which is the minimum of two double variables
Declaration
public static Variable<double> Min(Variable<double> a, Variable<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | a | The first variable |
| Variable<Double> | b | The second variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> | A new variable |
Min(Variable<Int32>, Variable<Int32>)
Returns an int variable which is the minimum of two int variables
Declaration
public static Variable<int> Min(Variable<int> a, Variable<int> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | a | The first variable |
| Variable<Int32> | b | The second variable |
Returns
| Type | Description |
|---|---|
| Variable<Int32> | A new variable |
Multinomial(Range, Variable<Vector>)
Creates an array x of random integers where x[i] is the number of times that value i is drawn in the given number of trials.
Declaration
public static VariableArray<int> Multinomial(Range trials, Variable<Vector> probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | trials | A range whose length is the number of trials. This is becomes the ValueRange for each x[i]. |
| Variable<Vector> | probs | A variable containing the probability distribution for drawing each value per trial. Must have a ValueRange attribute specifying the number of possible values. |
Returns
| Type | Description |
|---|---|
| VariableArray<Int32> |
Multinomial(Variable<Int32>, Vector)
Creates an array x of random integers where x[i] is the number of times that value i is drawn in the given number of trials.
Declaration
public static VariableArray<int> Multinomial(Variable<int> trialCount, Vector probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | trialCount | The number of trials |
| Vector | probs | A variable containing the probability distribution for drawing each value per trial. Must have a ValueRange attribute specifying the number of possible values. |
Returns
| Type | Description |
|---|---|
| VariableArray<Int32> |
Multinomial(Variable<Int32>, Variable<Vector>)
Creates an array x of random integers where x[i] is the number of times that value i is drawn in the given number of trials.
Declaration
public static VariableArray<int> Multinomial(Variable<int> trialCount, Variable<Vector> probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | trialCount | The number of trials |
| Variable<Vector> | probs | A variable containing the probability distribution for drawing each value per trial. Must have a ValueRange attribute specifying the number of possible values. |
Returns
| Type | Description |
|---|---|
| VariableArray<Int32> |
MultinomialList(Variable<Int32>, Variable<Vector>)
Creates a list x of random integers where x[i] is the number of times that value i is drawn in the given number of trials.
Declaration
public static VariableArray<Variable<int>, IList<int>> MultinomialList(Variable<int> trialCount, Variable<Vector> probs)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | trialCount | The number of trials |
| Variable<Vector> | probs | A variable containing the probability distribution for drawing each value per trial. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<Int32>, IList<Int32>> | A variable containing a list of counts |
New<T>()
Creates a variable with no statistical definition.
Declaration
public static Variable<T> New<T>()
Returns
| Type | Description |
|---|---|
| Variable<T> | A random variable without a statistical definition. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Remarks
This method is intended for constructing variables whose statistical definition is conditional, and will be provided later using If/Case/Switch blocks.
Observed<T>(T)
Creates a variable and observes it.
Declaration
public static Variable<T> Observed<T>(T observedValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T | observedValue | The observed value |
Returns
| Type | Description |
|---|---|
| Variable<T> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed value |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[])
Creates a variable array and observes it.
Declaration
public static VariableArray<T> Observed<T>(T[] observedValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | observedValue | The observed value |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[], Range)
Creates a variable array and observes it.
Declaration
public static VariableArray<T> Observed<T>(T[] observedValue, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | observedValue | The observed value |
| Range | r | The range used to index the array |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[][], Range, Range)
Creates a jagged variable array and observes it.
Declaration
public static VariableArray<VariableArray<T>, T[][]> Observed<T>(T[][] observedValue, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| T[][] | observedValue | The observed value |
| Range | r1 | The range used for the first index |
| Range | r2 | The range used for the second index |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[][][], Range, Range, Range)
Creates a jagged variable array and observes it.
Declaration
public static VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]> Observed<T>(T[][][] observedValue, Range r1, Range r2, Range r3)
Parameters
| Type | Name | Description |
|---|---|---|
| T[][][] | observedValue | The observed value |
| Range | r1 | The range used for the first index |
| Range | r2 | The range used for the second index |
| Range | r3 | The range used for the third index |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[][][][], Range, Range, Range, Range)
Creates a jagged variable array and observes it.
Declaration
public static VariableArray<VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]>, T[][][][]> Observed<T>(T[][][][] observedValue, Range r1, Range r2, Range r3, Range r4)
Parameters
| Type | Name | Description |
|---|---|---|
| T[][][][] | observedValue | The observed value |
| Range | r1 | The range used for the first index |
| Range | r2 | The range used for the second index |
| Range | r3 | The range used for the third index |
| Range | r4 | The range used for the fourth index |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]>, T[][][][]> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[,])
Creates a 2D variable array and observes it.
Declaration
public static VariableArray2D<T> Observed<T>(T[, ] observedValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T[,] | observedValue | The observed value |
Returns
| Type | Description |
|---|---|
| VariableArray2D<T> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(T[,], Range, Range)
Creates a 2D variable array and observes it.
Declaration
public static VariableArray2D<T> Observed<T>(T[, ] observedValue, Range r0, Range r1)
Parameters
| Type | Name | Description |
|---|---|---|
| T[,] | observedValue | The observed value |
| Range | r0 | The range used for the first index |
| Range | r1 | The range used for the second index |
Returns
| Type | Description |
|---|---|
| VariableArray2D<T> | A new variable |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(IReadOnlyList<T>)
Creates a variable array and observes it.
Declaration
public static VariableArray<Variable<T>, IReadOnlyList<T>> Observed<T>(IReadOnlyList<T> observedValue)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<T> | observedValue | The observed value. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IReadOnlyList<T>> | A new variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(IReadOnlyList<T>, Range)
Creates a variable array and observes it.
Declaration
public static VariableArray<Variable<T>, IReadOnlyList<T>> Observed<T>(IReadOnlyList<T> observedValue, Range r)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<T> | observedValue | The observed value. |
| Range | r | The range used to index the array. |
Returns
| Type | Description |
|---|---|
| VariableArray<Variable<T>, IReadOnlyList<T>> | A new variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Observed<T>(IReadOnlyList<IReadOnlyList<T>>, Range, Range)
Creates a jagged variable array and observes it.
Declaration
public static VariableArray<VariableArray<Variable<T>, IReadOnlyList<T>>, IReadOnlyList<IReadOnlyList<T>>> Observed<T>(IReadOnlyList<IReadOnlyList<T>> observedValue, Range r1, Range r2)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<IReadOnlyList<T>> | observedValue | The observed value. |
| Range | r1 | The range used for the first index. |
| Range | r2 | The range used for the second index. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<Variable<T>, IReadOnlyList<T>>, IReadOnlyList<IReadOnlyList<T>>> | A new variable. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the observed array elements. |
Remarks
The variable is not constant; its ObservedValue can be changed.
Poisson(Variable<Double>)
Creates a Poisson-distributed random variable with the mean represented by a random variable.
Declaration
public static Variable<int> Poisson(Variable<double> mean)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | mean | A random variable that represents the mean. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> |
Poisson(Double)
Creates a Poisson-distributed random variable with a specified mean.
Declaration
public static Variable<int> Poisson(double mean)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | mean | The mean. |
Returns
| Type | Description |
|---|---|
| Variable<Int32> |
Potts(Variable<Boolean>, Variable<Boolean>, Variable<Double>)
Adds a Potts factor between two boolean variables (max product only!).
Declaration
public static void Potts(Variable<bool> a, Variable<bool> b, Variable<double> logCost)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Boolean> | a | The first bool variable |
| Variable<Boolean> | b | The second bool variable |
| Variable<Double> | logCost | The negative log cost if the variables are not equal |
Remarks
This factor has the value of 1 if a==b and exp(-logCost) otherwise.
Potts(Variable<Int32>, Variable<Int32>, Variable<Double>)
Adds a Potts factor between two int variables (max product only!).
Declaration
public static void Potts(Variable<int> a, Variable<int> b, Variable<double> logCost)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | a | The first int variable |
| Variable<Int32> | b | The second int variable |
| Variable<Double> | logCost | The negative log cost if the variables are not equal |
Remarks
This factor has the value of 1 if a==b and exp(-logCost) otherwise.
ProductExp(Variable<Double>, Variable<Double>)
Returns a Gaussian variable which is the product of A times the exponential of B.
Declaration
public static Variable<double> ProductExp(Variable<double> A, Variable<double> B)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | A | |
| Variable<Double> | B |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
Random<T>(IDistribution<T>)
Creates a random variable with a specified prior distribution.
Declaration
public static Variable<T> Random<T>(IDistribution<T> dist)
Parameters
| Type | Name | Description |
|---|---|---|
| IDistribution<T> | dist | The prior distribution. |
Returns
| Type | Description |
|---|---|
| Variable<T> | Returns a random variable that is statistically defined by the specified prior. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Random<T, TDist>(Variable<TDist>)
Creates a random variable with a specified prior distribution.
Declaration
public static Variable<T> Random<T, TDist>(Variable<TDist> dist)
where TDist : IDistribution<T>
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<TDist> | dist | The prior distribution. |
Returns
| Type | Description |
|---|---|
| Variable<T> | Returns a random variable that is statistically defined by the specified prior. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
| TDist | The distribution type. |
Remarks
Consider using Random<TDist>(Variable<TDist>) instead, as then the second type can be automatically inferred.
RegisterOperatorFactor(Variable.Operator, Delegate)
Registers a factor method against a particular operator.
Declaration
public static void RegisterOperatorFactor(Variable.Operator op, Delegate factorMethod)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable.Operator | op | The operator to register against |
| Delegate | factorMethod | The factor method to register |
RemoveAllAttributes<AttributeType>()
Remove all attributes of the specified type
Declaration
public void RemoveAllAttributes<AttributeType>()
Type Parameters
| Name | Description |
|---|---|
| AttributeType | The attribute type to remove |
Repeat(Variable<Double>)
Creates a new 'repeat' block
Declaration
public static RepeatBlock Repeat(Variable<double> count)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | count | The count of times to repeat the contained block |
Returns
| Type | Description |
|---|---|
| RepeatBlock | The repeat block |
Replicate<T>(Variable<T>, Range)
Replicates a value multiple times.
Declaration
public static VariableArray<T> Replicate<T>(Variable<T> value, Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | value | The value to replicate. |
| Range | range | The range used to index the output array. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | The array of replicated values. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Replicate<T>(VariableArray<T>, Range)
Replicates an array multiple times.
Declaration
public static VariableArray<VariableArray<T>, T[][]> Replicate<T>(VariableArray<T> array, Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The array to replicate. |
| Range | range | The range used to index the output array. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | The array of replicated arrays. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Replicate<T>(VariableArray<VariableArray<T>, T[][]>, Range)
Replicates an array multiple times.
Declaration
public static VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]> Replicate<T>(VariableArray<VariableArray<T>, T[][]> array, Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<VariableArray<T>, T[][]> | array | The array to replicate. |
| Range | range | The range used to index the output array. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<VariableArray<T>, T[][]>, T[][][]> | The array of replicated arrays. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
Replicate<TItem, T>(VariableArray<VariableArray<TItem, T>, T[]>, Range)
Replicates an array multiple times.
Declaration
public static VariableArray<VariableArray<VariableArray<TItem, T>, T[]>, T[][]> Replicate<TItem, T>(VariableArray<VariableArray<TItem, T>, T[]> array, Range range)
where TItem : Variable, ICloneable, SettableTo<TItem>
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<VariableArray<TItem, T>, T[]> | array | The array to replicate. |
| Range | range | The range used to index the output array. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<VariableArray<TItem, T>, T[]>, T[][]> | The array of replicated arrays. |
Type Parameters
| Name | Description |
|---|---|
| TItem | The element variable type. |
| T | The domain type. |
Rotate(Variable<Double>, Variable<Double>, Variable<Double>)
A random vector equal to the vector (x,y) rotated by an angle about the origin.
Declaration
public static Variable<Vector> Rotate(Variable<double> x, Variable<double> y, Variable<double> angle)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | x | First coordinate of the vector to rotate |
| Variable<Double> | y | Second coordinate of the vector to rotate |
| Variable<Double> | angle | Counter-clockwise rotation angle in radians |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new variable |
SequentialCopy<T>(Variable<T>, out Variable<T>)
Creates two copies of the argument, that will be updated in order during inference.
Declaration
public static Variable<T> SequentialCopy<T>(Variable<T> v, out Variable<T> second)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T> | v | Variable to copy. |
| Variable<T> | second | The second copy. |
Returns
| Type | Description |
|---|---|
| Variable<T> | The first copy. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type. |
SequentialCopy<T>(VariableArray<T>, out VariableArray<T>)
Creates two copies of the argument, that will be updated in order during inference.
Declaration
public static VariableArray<T> SequentialCopy<T>(VariableArray<T> array, out VariableArray<T> second)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | Array to copy. |
| VariableArray<T> | second | The second copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | The first copy. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of an array element. |
SequentialCopy<T>(VariableArray<VariableArray<T>, T[][]>, out VariableArray<VariableArray<T>, T[][]>)
Creates two copies of the argument, that will be updated in order during inference.
Declaration
public static VariableArray<VariableArray<T>, T[][]> SequentialCopy<T>(VariableArray<VariableArray<T>, T[][]> array, out VariableArray<VariableArray<T>, T[][]> second)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<VariableArray<T>, T[][]> | array | Array to copy. |
| VariableArray<VariableArray<T>, T[][]> | second | The second copy. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | The first copy. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of an array element. |
SetSparsity(Sparsity)
Sets the Sparsity attribute of this variable, replacing any previously set.
Declaration
public void SetSparsity(Sparsity sparsity)
Parameters
| Type | Name | Description |
|---|---|---|
| Sparsity | sparsity | A sparsity specification for vector messages |
SetValueRange(Range)
Sets the ValueRange attribute of this variable, replacing any previously set.
Declaration
public void SetValueRange(Range valueRange)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | valueRange | A range defining the set of values this variable can take on. Only meaningful for Variable<int> and Variable<Vector> |
ShorterIsPrefixOfLonger<T>(IReadOnlyList<T>, IReadOnlyList<T>)
True if the shorter list is a prefix of the longer list.
Declaration
protected static bool ShorterIsPrefixOfLonger<T>(IReadOnlyList<T> a, IReadOnlyList<T> b)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<T> | a | |
| IReadOnlyList<T> | b |
Returns
| Type | Description |
|---|---|
| Boolean |
Type Parameters
| Name | Description |
|---|---|
| T |
Softmax(Variable<ISparseList<Double>>)
Creates a vector variable y where y[i] = exp(x[i])/(sum_j exp(x[j])). y has the same length as x.
Declaration
public static Variable<Vector> Softmax(Variable<ISparseList<double>> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<ISparseList<Double>> | x | The sparse list variable argument |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new variable |
Softmax(Variable<Vector>)
Creates a vector variable y where y[i] = exp(x[i])/(sum_j exp(x[j])). y has the same length as x.
Declaration
public static Variable<Vector> Softmax(Variable<Vector> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | x | The vector variable argument |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new variable |
Softmax(Variable<IList<Double>>)
Creates a vector variable y where y[i] = exp(x[i])/(sum_j exp(x[j])). y has the same length as x.
Declaration
public static Variable<Vector> Softmax(Variable<IList<double>> x)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IList<Double>> | x | The vector variable argument |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new variable |
Softmax(VariableArray<Double>)
Creates a vector variable y where y[i] = exp(x[i])/(sum_j exp(x[j])). y has the same length as x.
Declaration
public static Variable<Vector> Softmax(VariableArray<double> x)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Double> | x | The variable array argument |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new variable |
Split<T>(VariableArray<T>, Range, Range, out VariableArray<T>)
Creates two arrays by splitting a random array into disjoint pieces.
Declaration
public static VariableArray<T> Split<T>(VariableArray<T> array, Range headRange, Range tailRange, out VariableArray<T> tail)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array |
| Range | headRange | Specifies the number of elements to put into the returned array |
| Range | tailRange | The range associated with the tail array |
| VariableArray<T> | tail | On return, holds the remaining elements |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | The initial elements of |
Type Parameters
| Name | Description |
|---|---|
| T | The element type |
Split<TItem, T>(VariableArray<TItem, T[]>, Range, Range, out VariableArray<TItem, T[]>)
Creates two arrays by splitting a random array into disjoint pieces.
Declaration
public static VariableArray<TItem, T[]> Split<TItem, T>(VariableArray<TItem, T[]> array, Range headRange, Range tailRange, out VariableArray<TItem, T[]> tail)
where TItem : Variable, ICloneable, SettableTo<TItem>
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, T[]> | array | The source array |
| Range | headRange | Specifies the number of elements to put into the returned array |
| Range | tailRange | The range associated with the tail array |
| VariableArray<TItem, T[]> | tail | On return, holds the remaining elements |
Returns
| Type | Description |
|---|---|
| VariableArray<TItem, T[]> | The initial elements of |
Type Parameters
| Name | Description |
|---|---|
| TItem | The inner variable type |
| T | The domain type of array elements |
SplitSubarray<T>(VariableArray<T>, VariableArray<VariableArray<Int32>, Int32[][]>)
Gets a jagged variable array containing different items of a source list.
Declaration
public static VariableArray<VariableArray<T>, T[][]> SplitSubarray<T>(VariableArray<T> array, VariableArray<VariableArray<int>, int[][]> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array. |
| VariableArray<VariableArray<Int32>, Int32[][]> | indices | Jagged array containing the indices of the elements to get. The indices must all be different. The shape of this array determines the shape of the result. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<T>, T[][]> | variable array with the specified items. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use JaggedSubarray<T>(VariableArray<T>, VariableArray<VariableArray<Int32>, Int32[][]>) or GetItems<T>(Variable<T[]>, VariableArray<Int32>).
SplitSubarray<TItem, T>(VariableArray<TItem, T[]>, VariableArray<VariableArray<Int32>, Int32[][]>)
Gets a jagged variable array containing different items of a source list.
Declaration
public static VariableArray<VariableArray<TItem, T[]>, T[][]> SplitSubarray<TItem, T>(VariableArray<TItem, T[]> array, VariableArray<VariableArray<int>, int[][]> indices)
where TItem : Variable, ICloneable, SettableTo<TItem>
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, T[]> | array | The source array. |
| VariableArray<VariableArray<Int32>, Int32[][]> | indices | Jagged array containing the indices of the elements to get. The indices must all be different. The shape of this array determines the shape of the result. |
Returns
| Type | Description |
|---|---|
| VariableArray<VariableArray<TItem, T[]>, T[][]> | variable array with the specified items. |
Type Parameters
| Name | Description |
|---|---|
| TItem | The inner variable type |
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use JaggedSubarray<T>(VariableArray<T>, VariableArray<VariableArray<Int32>, Int32[][]>) or GetItems<T>(Variable<T[]>, VariableArray<Int32>).
String(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings with length in given bounds.
Declaration
public static Variable<string> String(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
String(Variable<Int32>, Variable<Int32>, Variable<DiscreteChar>)
Creates a string random variable from a uniform distribution over all strings with length in given bounds. String characters are restricted to be non zero probability characters under the given character distribution.
Declaration
public static Variable<string> String(Variable<int> minLength, Variable<int> maxLength, Variable<DiscreteChar> allowedCharacters)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
| Variable<DiscreteChar> | allowedCharacters | The distribution specifying the allowed string characters. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringCapitalized()
Creates a string random variable from a uniform distribution over all strings consisting of an uppercase letter followed by one or more lowercase letters.
Declaration
public static Variable<string> StringCapitalized()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringCapitalized(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings consisting of an uppercase letter followed by one or more lowercase letters, with length in specified bounds.
Declaration
public static Variable<string> StringCapitalized(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. Should be 2 or more. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringDigits()
Creates a string random variable from a uniform distribution over all non-empty strings of digits (see CharDigit()).
Declaration
public static Variable<string> StringDigits()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringDigits(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of digits (see CharDigit()) with length in given bounds.
Declaration
public static Variable<string> StringDigits(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringFormat(Variable<String>, Variable<String>[])
Replaces argument placeholders such as {0}, {1} etc with arguments having the corresponding index, similar to what Format(String, Object[]) does.
Declaration
public static Variable<string> StringFormat(Variable<string> format, params Variable<string>[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<String> | format | The string with argument placeholders. |
| Variable<String>[] | args | The array of arguments. |
Returns
| Type | Description |
|---|---|
| Variable<String> |
|
Remarks
This method has the following notable differences from Format(String, Object[]):
StringFormat(Variable<String>, VariableArray<String>)
Replaces argument placeholders such as {0}, {1} etc with arguments having the corresponding index, similar to what Format(String, Object[]) does.
Declaration
public static Variable<string> StringFormat(Variable<string> format, VariableArray<string> args)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<String> | format | The string with argument placeholders. |
| VariableArray<String> | args | The array of arguments. |
Returns
| Type | Description |
|---|---|
| Variable<String> |
|
Remarks
This method has the following notable differences from Format(String, Object[]):
StringFromArray(VariableArray<Char>)
Creates a string random variable from an array of characters.
Declaration
public static Variable<string> StringFromArray(VariableArray<char> chars)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Char> | chars | The array of characters. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
StringLetters()
Creates a string random variable from a uniform distribution over all non-empty strings of letters (see CharLetter()).
Declaration
public static Variable<string> StringLetters()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringLetters(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of letters (see CharLetter()) with length in given bounds.
Declaration
public static Variable<string> StringLetters(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringLettersOrDigits()
Creates a string random variable from a uniform distribution over all non-empty strings of letters or digits (see CharLetterOrDigit()).
Declaration
public static Variable<string> StringLettersOrDigits()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringLettersOrDigits(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of letters or digits (see CharLetterOrDigit()) with length in given bounds.
Declaration
public static Variable<string> StringLettersOrDigits(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringLower()
Creates a string random variable from a uniform distribution over all non-empty strings of lowercase letters (see CharLower()).
Declaration
public static Variable<string> StringLower()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringLower(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of lowercase letters (see CharLower()) with length in given bounds.
Declaration
public static Variable<string> StringLower(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringNonWord()
Creates a string random variable from a uniform distribution over all non-empty strings of non-word characters (see CharNonWord()).
Declaration
public static Variable<string> StringNonWord()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringNonWord(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of non-word characters (see CharNonWord()) with length in given bounds.
Declaration
public static Variable<string> StringNonWord(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length . |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringOfLength(Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of given length.
Declaration
public static Variable<string> StringOfLength(Variable<int> length)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | length | The desired string length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringOfLength(Variable<Int32>, Variable<DiscreteChar>)
Creates a string random variable from a uniform distribution over all strings of given length. String characters are restricted to be non zero probability characters under the given character distribution.
Declaration
public static Variable<string> StringOfLength(Variable<int> length, Variable<DiscreteChar> allowedCharacters)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | length | The desired string length. |
| Variable<DiscreteChar> | allowedCharacters | The distribution specifying the allowed string characters. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringUniform()
Creates a string random variable from a uniform distribution over all possible strings.
Declaration
public static Variable<string> StringUniform()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringUpper()
Creates a string random variable from a uniform distribution over all non-empty strings of uppercase letters (see CharUpper()).
Declaration
public static Variable<string> StringUpper()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringUpper(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of uppercase letters (see CharUpper()) with length in given bounds.
Declaration
public static Variable<string> StringUpper(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringWhitespace()
Creates a string random variable from a uniform distribution over all non-empty strings of whitespace characters (see CharWhitespace()).
Declaration
public static Variable<string> StringWhitespace()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringWhitespace(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of whitespace characters (see CharWhitespace()) with length in given bounds.
Declaration
public static Variable<string> StringWhitespace(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
StringWord()
Creates a string random variable from a uniform distribution over all non-empty strings of word characters (see CharWord()).
Declaration
public static Variable<string> StringWord()
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
The resulting random variable has an improper distribution.
StringWord(Variable<Int32>, Variable<Int32>)
Creates a string random variable from a uniform distribution over all strings of word characters (see CharWord()) with length in given bounds.
Declaration
public static Variable<string> StringWord(Variable<int> minLength, Variable<int> maxLength = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | minLength | The minimum possible string length. |
| Variable<Int32> | maxLength | The maximum possible string length. If null, there will be no upper limit on length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable. |
Remarks
If maxLength is set to null,
the resulting random variable has an improper distribution.
Subarray<T>(Variable<T[]>, VariableArray<Int32>)
Gets a variable array containing different items of a source array.
Declaration
public static VariableArray<T> Subarray<T>(Variable<T[]> array, VariableArray<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<T[]> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. The indices must all be different. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Subarray<T>(Variable<IReadOnlyList<T>>, VariableArray<Int32>)
Gets a variable array containing different items of a source list
Declaration
public static VariableArray<T> Subarray<T>(Variable<IReadOnlyList<T>> array, VariableArray<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IReadOnlyList<T>> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. The indices must all be different. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Subarray<T>(VariableArray<T>, VariableArray<Variable<Int32>, IReadOnlyList<Int32>>)
Gets a variable array containing different items of a source list.
Declaration
public static VariableArray<T> Subarray<T>(VariableArray<T> array, VariableArray<Variable<int>, IReadOnlyList<int>> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array. |
| VariableArray<Variable<Int32>, IReadOnlyList<Int32>> | indices | Variable array containing the indices of the elements to get. The indices must all be different. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items. |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Subarray<T>(VariableArray<T>, VariableArray<Int32>)
Gets a variable array containing different items of a source list
Declaration
public static VariableArray<T> Subarray<T>(VariableArray<T> array, VariableArray<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. The indices must all be different. |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Subarray<TItem, T>(VariableArray<TItem, T[]>, VariableArray<Int32>)
Gets a variable array containing different items of a source list
Declaration
public static VariableArray<TItem, T[]> Subarray<TItem, T>(VariableArray<TItem, T[]> array, VariableArray<int> indices)
where TItem : Variable, ICloneable, SettableTo<TItem>
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<TItem, T[]> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. The indices must all be different. |
Returns
| Type | Description |
|---|---|
| VariableArray<TItem, T[]> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| TItem | The inner variable type |
| T | The domain type of array elements |
Remarks
To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Subarray2<T>(VariableArray<T>, VariableArray<Int32>, VariableArray<T>)
Gets a variable array containing different items of two source lists
Declaration
public static VariableArray<T> Subarray2<T>(VariableArray<T> array, VariableArray<int> indices, VariableArray<T> array2)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<T> | array | The source array |
| VariableArray<Int32> | indices | Variable array containing the indices of the elements to get. The indices must all be different. Any index less than zero corresponds to fetching from the second source array at the same position. |
| VariableArray<T> | array2 | The second source array |
Returns
| Type | Description |
|---|---|
| VariableArray<T> | variable array with the specified items |
Type Parameters
| Name | Description |
|---|---|
| T | The domain type of array elements. |
Remarks
To allow duplicate indices, use GetItems<T>(Variable<T[]>, VariableArray<Int32>).
Substring(Variable<String>, Variable<Int32>, Variable<Int32>)
Creates a string random variable which is a substring of a given string.
Declaration
public static Variable<string> Substring(Variable<string> str, Variable<int> start, Variable<int> length)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<String> | str | The string. |
| Variable<Int32> | start | The substring start index. |
| Variable<Int32> | length | The substring length. |
Returns
| Type | Description |
|---|---|
| Variable<String> | The created random variable for the substring of |
Subvector(Variable<Vector>, Variable<Int32>, Variable<Int32>)
Copy a contiguous subvector of a random vector.
Declaration
public static Variable<Vector> Subvector(Variable<Vector> source, Variable<int> startIndex, Variable<int> count)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | source | Random vector |
| Variable<Int32> | startIndex | Index of the first element to copy |
| Variable<Int32> | count | Number of elements to copy |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new vector variable whose value is equal to |
Sum(Variable<Vector[]>)
Returns a Vector(Variable<Double[]>) variable which is the sum of the elements of an array variable.
Declaration
public static Variable<Vector> Sum(Variable<Vector[]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector[]> | array | The array variable. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> |
|
Sum(Variable<IList<Vector>>)
Returns a Vector(Variable<Double[]>) variable which is the sum of the elements of an array variable.
Declaration
public static Variable<Vector> Sum(Variable<IList<Vector>> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IList<Vector>> | array | The array variable. |
Returns
| Type | Description |
|---|---|
| Variable<Vector> |
|
Sum(Variable<IList<Double>>)
Returns a double variable which is the sum of the elements of an array variable. For sum of two variables, use the + operator.
Declaration
public static Variable<double> Sum(Variable<IList<double>> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<IList<Double>> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
Sum(Variable<Double[]>)
Returns a double variable which is the sum of the elements of an array variable. For sum of two variables, use the + operator.
Declaration
public static Variable<double> Sum(Variable<double[]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double[]> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
Sum(Variable<Int32[]>)
Returns a double variable which is the sum of the elements of an array variable. For sum of two variables, use the + operator.
Declaration
public static Variable<int> Sum(Variable<int[]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32[]> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Int32> |
|
Sum_Expanded(VariableArray<Double>)
Returns a double variable which is the sum of the elements of an array variable. For sum of two variables, use the + operator.
Declaration
public static Variable<double> Sum_Expanded(VariableArray<double> array)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Double> | array | The array variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
SumWhere(VariableArray<Boolean>, Variable<Vector>)
Returns a double random variable which is the inner product of a array of binary variables and a vector variable.
Declaration
public static Variable<double> SumWhere(VariableArray<bool> a, Variable<Vector> b)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Boolean> | a | The first, binary vector variable |
| Variable<Vector> | b | The second vector variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
SumWhere(VariableArray<Boolean>, VariableArray<Double>)
Returns a double random variable which is the inner product of a array of binary variables and an array of double variables.
Declaration
public static Variable<double> SumWhere(VariableArray<bool> a, VariableArray<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| VariableArray<Boolean> | a | A binary array variable |
| VariableArray<Double> | b | A double array variable |
Returns
| Type | Description |
|---|---|
| Variable<Double> |
|
Switch(Variable<Int32>)
Opens a stochastic switch statement using the specified condition variable. This is equivalent to creating a set of identical Variable.Case() statements for each value of i. Within a switch block, you can use the variable i as an array index.
Declaration
public static SwitchBlock Switch(Variable<int> i)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Int32> | i | The condition of the switch block |
Returns
| Type | Description |
|---|---|
| SwitchBlock | A SwitchBlock object which must be closed before inference is performed. |
Remarks
This method should be used as the argument to a using() statement, so that the if statement is automatically closed. If this is not possible, the returned SwitchBlock must be closed manually by calling CloseBlock().
ToString()
Overridden ToString method
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
TruncatedGammaFromShapeAndRate(Variable<Double>, Variable<Double>, Variable<Double>, Variable<Double>)
Returns a random variable that is statistically defined by a truncated Gamma distribution with specified shape, rate and bounds.
Declaration
public static Variable<double> TruncatedGammaFromShapeAndRate(Variable<double> shape, Variable<double> rate, Variable<double> lowerBound, Variable<double> upperBound)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | shape | The shape. |
| Variable<Double> | rate | The rate. |
| Variable<Double> | lowerBound | The distribution's upper bound. |
| Variable<Double> | upperBound | The distribution's lower bound. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a truncated Gamma-distributed random variable with the specified shape, rate, and bounds. |
TruncatedGaussian(Double, Double, Double, Double)
Returns a random variable that is statistically defined by a truncated Gaussian distribution with specified mean, variance and bounds.
Declaration
public static Variable<double> TruncatedGaussian(double mean, double variance, double lowerBound, double upperBound)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | mean | The mean. |
| Double | variance | The variance. |
| Double | lowerBound | The distribution's upper bound. |
| Double | upperBound | The distribution's lower bound. |
Returns
| Type | Description |
|---|---|
| Variable<Double> | Returns a truncated Gaussian-distributed random variable with the specified mean, variance, and bounds. |
Vector(Variable<Double[]>)
Create a random Vector from values in an array.
Declaration
public static Variable<Vector> Vector(Variable<double[]> array)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double[]> | array | A random array |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | A new vector variable whose value is equal to |
VectorGaussianFromMeanAndPrecision(Vector, PositiveDefiniteMatrix)
Creates a Gaussian-distributed random vector with a specified mean and precision matrix.
Declaration
public static Variable<Vector> VectorGaussianFromMeanAndPrecision(Vector mean, PositiveDefiniteMatrix precision)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | mean | A |
| PositiveDefiniteMatrix | precision | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a vector Gaussian-distributed random variable with the specified mean and precision matrix. |
VectorGaussianFromMeanAndPrecision(Variable<Vector>, Variable<PositiveDefiniteMatrix>)
Creates a vector Gaussian-distributed random vector with the mean and precision matrix represented by random variables.
Declaration
public static Variable<Vector> VectorGaussianFromMeanAndPrecision(Variable<Vector> mean, Variable<PositiveDefiniteMatrix> precision)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | mean | A |
| Variable<PositiveDefiniteMatrix> | precision | A |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Returns a vector Gaussian-distributed random variable with the specified mean and precision matrix. |
VectorGaussianFromMeanAndVariance(Vector, PositiveDefiniteMatrix)
Creates a Gaussian-distributed random vector from a mean vector and variance positive definite matrix.
Declaration
public static Variable<Vector> VectorGaussianFromMeanAndVariance(Vector mean, PositiveDefiniteMatrix variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | mean | The mean vector of the Gaussian |
| PositiveDefiniteMatrix | variance | The variance matrix of the Gaussian |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Gaussian-distributed random vector variable |
VectorGaussianFromMeanAndVariance(Variable<Vector>, PositiveDefiniteMatrix)
Creates a Gaussian-distributed random vector from a mean vector and variance positive definite matrix.
Declaration
public static Variable<Vector> VectorGaussianFromMeanAndVariance(Variable<Vector> mean, PositiveDefiniteMatrix variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | mean | A variable containing mean vector of the Gaussian |
| PositiveDefiniteMatrix | variance | The variance matrix of the Gaussian |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Gaussian-distributed random vector variable |
VectorGaussianFromMeanAndVariance(Variable<Vector>, Variable<PositiveDefiniteMatrix>)
Creates a Gaussian-distributed random vector from a mean vector and variance positive definite matrix.
Declaration
public static Variable<Vector> VectorGaussianFromMeanAndVariance(Variable<Vector> mean, Variable<PositiveDefiniteMatrix> variance)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | mean | A variable containing mean vector of the Gaussian |
| Variable<PositiveDefiniteMatrix> | variance | The variance matrix of the Gaussian |
Returns
| Type | Description |
|---|---|
| Variable<Vector> | Gaussian-distributed random vector variable |
VectorTimesScalar(Variable<Vector>, Variable<Double>)
Creates a vector variable whose [i] entry equals a[i]*b
Declaration
public static Variable<Vector> VectorTimesScalar(Variable<Vector> a, Variable<double> b)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Vector> | a | The vector |
| Variable<Double> | b | The scalar |
Returns
| Type | Description |
|---|---|
| Variable<Vector> |
WishartFromShapeAndRate(Variable<Double>, Variable<PositiveDefiniteMatrix>)
Creates a Wishart-distributed random matrix with the shape and rate represented by random variables.
Declaration
public static Variable<PositiveDefiniteMatrix> WishartFromShapeAndRate(Variable<double> shape, Variable<PositiveDefiniteMatrix> rate)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | shape | A |
| Variable<PositiveDefiniteMatrix> | rate | A |
Returns
| Type | Description |
|---|---|
| Variable<PositiveDefiniteMatrix> | Returns a Wishart-distributed random variable with the specified shape and rate matrix. |
WishartFromShapeAndScale(Variable<Double>, Variable<PositiveDefiniteMatrix>)
Creates a Wishart-distributed random matrix with the shape and scale represented by random variables.
Declaration
public static Variable<PositiveDefiniteMatrix> WishartFromShapeAndScale(Variable<double> shape, Variable<PositiveDefiniteMatrix> scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Variable<Double> | shape | A |
| Variable<PositiveDefiniteMatrix> | scale | A |
Returns
| Type | Description |
|---|---|
| Variable<PositiveDefiniteMatrix> | Returns a Wishart-distributed random variable with the specified shape and scale matrix. |
WishartFromShapeAndScale(Double, PositiveDefiniteMatrix)
Creates a Wishart-distributed random variable with specified shape and scale.
Declaration
public static Variable<PositiveDefiniteMatrix> WishartFromShapeAndScale(double shape, PositiveDefiniteMatrix scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | shape | The shape. |
| PositiveDefiniteMatrix | scale | The scale matrix. |
Returns
| Type | Description |
|---|---|
| Variable<PositiveDefiniteMatrix> | Returns a Wishart-distributed random variable with the specified shape and scale matrix. |
Explicit Interface Implementations
HasObservedValue.ObservedValue
Observed value property
Declaration
object HasObservedValue.ObservedValue { get; set; }
Returns
| Type | Description |
|---|---|
| Object |
IModelExpression.Name
Declaration
string IModelExpression.Name { get; }
Returns
| Type | Description |
|---|---|
| String |