Miscellaneous Factors
This page lists the remaining built-in methods, which have not already been covered. In these methods, you can often pass in random variables as arguments e.g. Variable<Vector> instead of Vector. For compactness, this is not shown in the syntax below.
These methods provide a convenient short alternative to using Variable<T>.Factor and passing in the factor method, as described on this page.
|
Operation |
Syntax |
Description |
| Subarray |
Variable.Subarray<T>(T[] array, int[] indices) |
Create a T[] random variable array by extracting elements of array at the specified indices, which cannot include duplicates.
Subarray should be used instead of GetItems, whenever you can be sure that there are no duplicates, since it is more efficient. |
|
GetItems |
Variable.GetItems<T>(T[] array, int[] indices)
|
Create a T[] random variable array by extracting elements of array at the specified indices, which may include duplicates. Some uses of GetItems can also be achieved through indexing. If there are no duplicate indices, Subarray should be used instead. |
|
Enum to int (experimental) |
Variable.EnumToInt<TEnum>(TEnum enumVar) |
Creates an int random variable corresponding to the supplied enum random variable. This allows enums to be used as arguments to Variable.Case() or Variable.Switch(). |
| Concat (experimental) |
Variable.Concat(first, second) |
Concatenates two random Vectors. |
| Subvector (experimental) |
Variable.Subvector(vector, startIndex, count) |
Extract contiguous elements from a random vector. |
| GetItem |
Variable.GetItem(vector, index) |
Extract an element of a random vector. |
Last modified at 8/25/2009 4:44 PM by Tom Minka
|
|