Search Results for

    Show / Hide Table of Contents

    Class Factor

    Contains commonly used factor methods.

    Inheritance
    Object
    Factor
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Microsoft.ML.Probabilistic.Factors
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Quality(QualityBand.Stable)]
    public static class Factor

    Methods

    AllTrue(IList<Boolean>)

    True if all array elements are true.

    Declaration
    public static bool AllTrue(IList<bool> array)
    Parameters
    Type Name Description
    IList<Boolean> array
    Returns
    Type Description
    Boolean

    AND_i array[i]

    And(Boolean, Boolean)

    Logical and of two booleans

    Declaration
    public static bool And(bool a, bool b)
    Parameters
    Type Name Description
    Boolean a

    First bool

    Boolean b

    Second bool

    Returns
    Type Description
    Boolean

    a&b

    AreEqual(Boolean, Boolean)

    Test if two booleans are equal.

    Declaration
    public static bool AreEqual(bool a, bool b)
    Parameters
    Type Name Description
    Boolean a

    First bool

    Boolean b

    Second bool

    Returns
    Type Description
    Boolean

    True if a==b.

    AreEqual(Double, Double)

    Test if two doubles are equal.

    Declaration
    public static bool AreEqual(double a, double b)
    Parameters
    Type Name Description
    Double a

    First double

    Double b

    Second double

    Returns
    Type Description
    Boolean

    True if a==b.

    AreEqual(Int32, Int32)

    Test if two integers are equal.

    Declaration
    public static bool AreEqual(int a, int b)
    Parameters
    Type Name Description
    Int32 a

    First integer

    Int32 b

    Second integer

    Returns
    Type Description
    Boolean

    True if a==b.

    AreEqual(String, String)

    Tests if two strings are equal.

    Declaration
    public static bool AreEqual(string str1, string str2)
    Parameters
    Type Name Description
    String str1

    The first string.

    String str2

    The second string.

    Returns
    Type Description
    Boolean

    true if the strings are equal, false otherwise.

    ArrayFromVector(Vector)

    Convert a Vector into an array of doubles.

    Declaration
    [ParameterNames(new string[]{"array", "vector"})]
    public static double[] ArrayFromVector(Vector vector)
    Parameters
    Type Name Description
    Vector vector
    Returns
    Type Description
    Double[]

    A new array

    Bernoulli(Double)

    Sample from a Bernoulli distribution.

    Declaration
    [ParameterNames(new string[]{"sample", "probTrue"})]
    public static bool Bernoulli(double probTrue)
    Parameters
    Type Name Description
    Double probTrue

    The probability that the result is true.

    Returns
    Type Description
    Boolean

    A random boolean value.

    BernoulliFromBoolean(Boolean, Double, Double)

    Sample from one of two Bernoulli distributions. This factor is DEPRECATED. Use Gates instead.

    Declaration
    [Obsolete("Use Gates instead")]
    [ParameterNames(new string[]{"sample", "choice", "probTrue0", "probTrue1"})]
    public static bool BernoulliFromBoolean(bool choice, double probTrueElseChoice, double probTrueIfChoice)
    Parameters
    Type Name Description
    Boolean choice

    Indicates which distribution to sample from.

    Double probTrueElseChoice

    The probability that the result is true, if choice is false.

    Double probTrueIfChoice

    The probability that the result is true, if choice is true.

    Returns
    Type Description
    Boolean

    A random boolean value.

    BernoulliFromBoolean(Boolean, Double[])

    Sample from one of two Bernoulli distributions. This factor is DEPRECATED. Use Gates instead.

    Declaration
    [ParameterNames(new string[]{"sample", "choice", "probTrue"})]
    [Obsolete("Use Gates instead")]
    public static bool BernoulliFromBoolean(bool choice, params double[] probTrue)
    Parameters
    Type Name Description
    Boolean choice

    Indicates which distribution to sample from.

    Double[] probTrue

    The probability that the result is true, for each choice.

    Returns
    Type Description
    Boolean

    A random boolean value.

    BernoulliFromDiscrete(Int32, Double[])

    Sample from one of many Bernoulli distributions. This factor is DEPRECATED. Use Gates instead.

    Declaration
    [ParameterNames(new string[]{"sample", "index", "probTrue"})]
    [Obsolete("Use Gates instead")]
    public static bool BernoulliFromDiscrete(int index, params double[] probTrue)
    Parameters
    Type Name Description
    Int32 index

    The index of the distribution to sample from.

    Double[] probTrue

    The probability that the result is true, for each index.

    Returns
    Type Description
    Boolean

    A random boolean value.

    BernoulliFromLogOdds(Double)

    Sample from a Bernoulli distribution with specified log odds

    Declaration
    [ParameterNames(new string[]{"sample", "logOdds"})]
    public static bool BernoulliFromLogOdds(double logOdds)
    Parameters
    Type Name Description
    Double logOdds
    Returns
    Type Description
    Boolean

    BetaFromMeanAndTotalCount(Double, Double)

    Sample from a Beta distribution

    Declaration
    [ParameterNames(new string[]{"prob", "mean", "totalCount"})]
    public static double BetaFromMeanAndTotalCount(double mean, double totalCount)
    Parameters
    Type Name Description
    Double mean

    Mean of the distribution.

    Double totalCount

    Total count (precision) of the distribution.

    Returns
    Type Description
    Double

    A sample from the distribution, i.e. a value in [0,1].

    Char(Vector)

    Samples a character from a given probability distribution over characters.

    Declaration
    [ParameterNames(new string[]{"character", "probabilities"})]
    public static char Char(Vector probabilities)
    Parameters
    Type Name Description
    Vector probabilities

    A vector storing probabilities of individual characters.

    Returns
    Type Description
    Char

    The sampled character.

    Concat(Char, String)

    Concatenates a character and a string.

    Declaration
    [ParameterNames(new string[]{"concat", "ch", "str"})]
    public static string Concat(char ch, string str)
    Parameters
    Type Name Description
    Char ch

    The character.

    String str

    The string.

    Returns
    Type Description
    String

    The concatenation result.

    Concat(IList<Vector>)

    Declaration
    public static Vector Concat(IList<Vector> array)
    Parameters
    Type Name Description
    IList<Vector> array
    Returns
    Type Description
    Vector

    Concat(String, Char)

    Concatenates a string and a character.

    Declaration
    [ParameterNames(new string[]{"concat", "str", "ch"})]
    public static string Concat(string str, char ch)
    Parameters
    Type Name Description
    String str

    The string.

    Char ch

    The character.

    Returns
    Type Description
    String

    The concatenation result.

    Concat(String, String)

    Concatenates given strings.

    Declaration
    [ParameterNames(new string[]{"concat", "str1", "str2"})]
    public static string Concat(string str1, string str2)
    Parameters
    Type Name Description
    String str1

    The first string.

    String str2

    The second string.

    Returns
    Type Description
    String

    The concatenation result.

    CountTrue(Boolean[])

    Count the number of true values in the given boolean array.

    Declaration
    [ParameterNames(new string[]{"count", "array"})]
    public static int CountTrue(bool[] array)
    Parameters
    Type Name Description
    Boolean[] array

    The array of booleans.

    Returns
    Type Description
    Int32

    Number of true values in the given array.

    Difference(Double, Double)

    Returns the difference of the two arguments: (a - b).

    Declaration
    public static double Difference(double a, double b)
    Parameters
    Type Name Description
    Double a
    Double b
    Returns
    Type Description
    Double

    a-b

    Difference(Int32, Int32)

    Returns the difference of the two arguments: (a - b).

    Declaration
    public static int Difference(int a, int b)
    Parameters
    Type Name Description
    Int32 a
    Int32 b
    Returns
    Type Description
    Int32

    a-b

    DirichletFromMeanAndTotalCount(Vector, Double)

    Sample from a Dirichlet distribution

    Declaration
    [ParameterNames(new string[]{"prob", "mean", "totalCount"})]
    public static Vector DirichletFromMeanAndTotalCount(Vector mean, double totalCount)
    Parameters
    Type Name Description
    Vector mean

    Mean of the distribution.

    Double totalCount

    Total count (precision) of the distribution.

    Returns
    Type Description
    Vector

    A sample from the distribution, a probability vector.

    DirichletSymmetric(Int32, Double)

    Sample from a symmetric Dirichlet distribution Dir(alpha,...,alpha)

    Declaration
    [ParameterNames(new string[]{"prob", "K", "alpha"})]
    public static Vector DirichletSymmetric(int K, double alpha)
    Parameters
    Type Name Description
    Int32 K

    Dimension of the distribution.

    Double alpha

    The hyperparameter.

    Returns
    Type Description
    Vector

    A sample from the distribution, a probability vector.

    Discrete(Vector)

    Sample from a discrete distribution.

    Declaration
    [ParameterNames(new string[]{"sample", "probs"})]
    public static int Discrete(Vector probs)
    Parameters
    Type Name Description
    Vector probs

    The probability of each outcome.

    Returns
    Type Description
    Int32

    A random integer from 0 to probs.Length-1

    Discrete(Int32, Matrix)

    Sample from one of several discrete distributions.

    Declaration
    [ParameterNames(new string[]{"sample", "selector", "probs"})]
    public static int Discrete(int selector, Matrix probs)
    Parameters
    Type Name Description
    Int32 selector

    Integer selecting which row of probs to sample from.

    Matrix probs

    Matrix holding discrete distributions as rows.

    Returns
    Type Description
    Int32

    DiscreteFromStickBreaking(Double[])

    Sample from a stick breaking distribution

    Declaration
    [ParameterNames(new string[]{"c", "v"})]
    public static int DiscreteFromStickBreaking(double[] v)
    Parameters
    Type Name Description
    Double[] v

    Stick lengths. The last value is ignored.

    Returns
    Type Description
    Int32

    A random integer in 0..(v.Length-1)

    DiscreteUniform(Int32)

    Sample from a uniform discrete distribution

    Declaration
    [ParameterNames(new string[]{"sample", "size"})]
    public static int DiscreteUniform(int size)
    Parameters
    Type Name Description
    Int32 size

    The dimension of the distribution (how many possibke distinct values

    Returns
    Type Description
    Int32

    A random integer from 0 to size-1

    Double(Int32)

    Convert an integer to a double-precision value

    Declaration
    public static double Double(int integer)
    Parameters
    Type Name Description
    Int32 integer
    Returns
    Type Description
    Double

    FunctionEvaluate(IFunction, Vector)

    Function evaluate factor

    Declaration
    [ParameterNames(new string[]{"y", "func", "x"})]
    public static double FunctionEvaluate(IFunction func, Vector x)
    Parameters
    Type Name Description
    IFunction func

    Function

    Vector x

    Function input

    Returns
    Type Description
    Double

    Function output

    GammaFromShapeAndRate(Double, Double)

    Sample from a Gamma with specified shape and scale

    Declaration
    [ParameterNames(new string[]{"sample", "shape", "rate"})]
    public static double GammaFromShapeAndRate(double shape, double rate)
    Parameters
    Type Name Description
    Double shape
    Double rate
    Returns
    Type Description
    Double

    Gaussian(Double, Double)

    Sample from a Gaussian distribution.

    Declaration
    [ParameterNames(new string[]{"sample", "mean", "precision"})]
    public static double Gaussian(double mean, double precision)
    Parameters
    Type Name Description
    Double mean

    The mean of the distribution.

    Double precision

    The precision of the distribution. The variance will be 1/precision.

    Returns
    Type Description
    Double

    A random real number.

    GaussianArrayArray(Int32, Double[], out Int32[][])

    Generate a jagged array of Gaussian random variables.

    Declaration
    [ParameterNames(new string[]{"samples", "sampleCount", "precisions", "indices"})]
    public static double[][] GaussianArrayArray(int sampleCount, double[] precisions, out int[][] indices)
    Parameters
    Type Name Description
    Int32 sampleCount
    Double[] precisions
    Int32[][] indices
    Returns
    Type Description
    Double[][]

    GaussianFromMeanAndVariance(Double, Double)

    Sample from a Gaussian distribution.

    Declaration
    [ParameterNames(new string[]{"sample", "mean", "variance"})]
    public static double GaussianFromMeanAndVariance(double mean, double variance)
    Parameters
    Type Name Description
    Double mean

    The mean of the distribution.

    Double variance

    The variance of the distribution. The precision will be 1/variance.

    Returns
    Type Description
    Double

    A random real number.

    InnerProduct(Double[], Vector)

    Returns the inner product between two vectors.

    Declaration
    [ParameterNames(new string[]{"X", "A", "B"})]
    public static double InnerProduct(double[] a, Vector b)
    Parameters
    Type Name Description
    Double[] a
    Vector b
    Returns
    Type Description
    Double

    sum_i a[i]*b[i]

    InnerProduct(Double[], Double[])

    Returns the inner product between two vectors.

    Declaration
    public static double InnerProduct(double[] a, double[] b)
    Parameters
    Type Name Description
    Double[] a
    Double[] b
    Returns
    Type Description
    Double

    sum_i a[i]*b[i]

    IsBetween(Double, Double, Double)

    Test if a number is between two bounds.

    Declaration
    public static bool IsBetween(double x, double lowerBound, double upperBound)
    Parameters
    Type Name Description
    Double x

    Any number besides NaN.

    Double lowerBound

    Any number besides NaN.

    Double upperBound

    Any number besides NaN.

    Returns
    Type Description
    Boolean

    True if (lowerBound <= x) and (x < upperBound)

    IsGreaterThan(Double, Double)

    Test if A is greater than B.

    Declaration
    public static bool IsGreaterThan(double a, double b)
    Parameters
    Type Name Description
    Double a

    First number

    Double b

    Second number

    Returns
    Type Description
    Boolean

    True if a > b

    IsGreaterThan(Int32, Int32)

    Test if A is greater than B.

    Declaration
    public static bool IsGreaterThan(int a, int b)
    Parameters
    Type Name Description
    Int32 a

    First number

    Int32 b

    Second number

    Returns
    Type Description
    Boolean

    True if a > b

    IsGreaterThan(UInt32, UInt32)

    Test if A is greater than B.

    Declaration
    public static bool IsGreaterThan(uint a, uint b)
    Parameters
    Type Name Description
    UInt32 a

    First number

    UInt32 b

    Second number

    Returns
    Type Description
    Boolean

    True if a > b

    IsPositive(Double)

    Test if a real number is positive.

    Declaration
    public static bool IsPositive(double x)
    Parameters
    Type Name Description
    Double x

    Any number besides NaN.

    Returns
    Type Description
    Boolean

    True if x>0.

    MatrixMultiply(Double[,], Double[,])

    Returns the product of two matrices.

    Declaration
    public static double[, ] MatrixMultiply(double[, ] A, double[, ] B)
    Parameters
    Type Name Description
    Double[,] A

    A two-dimensional array indexed by [row,col].

    Double[,] B

    A two-dimensional array indexed by [row,col].

    Returns
    Type Description
    Double[,]

    A two-dimensional array indexed by [row,col].

    MaxOfOthers(Double[])

    Compute an array where maxOfOthers[i] = max(array except i)

    Declaration
    public static double[] MaxOfOthers(double[] array)
    Parameters
    Type Name Description
    Double[] array
    Returns
    Type Description
    Double[]

    MultinomialList(Int32, Vector)

    Sample from a Multinomial distribution with specified probabilities and number of trials.

    Declaration
    [ParameterNames(new string[]{"sample", "trialCount", "p"})]
    public static IList<int> MultinomialList(int trialCount, Vector probs)
    Parameters
    Type Name Description
    Int32 trialCount

    Number of trials, >= 0

    Vector probs

    Must sum to 1

    Returns
    Type Description
    IList<Int32>

    A list of length probs.Count of integers between 0 and trialCount, whose sum is trialCount.

    Negate(Int32)

    Returns the negation of the argument.

    Declaration
    public static int Negate(int a)
    Parameters
    Type Name Description
    Int32 a
    Returns
    Type Description
    Int32

    Not(Boolean)

    Negate a boolean

    Declaration
    public static bool Not(bool b)
    Parameters
    Type Name Description
    Boolean b

    The bool

    Returns
    Type Description
    Boolean

    The negation of a boolean argument

    Or(Boolean, Boolean)

    Logical or of two booleans

    Declaration
    public static bool Or(bool a, bool b)
    Parameters
    Type Name Description
    Boolean a

    First bool

    Boolean b

    Second bool

    Returns
    Type Description
    Boolean

    a|b

    Plus(Vector, Vector)

    Returns the sum of the two arguments: (a + b).

    Declaration
    [ParameterNames(new string[]{"Sum", "A", "B"})]
    public static Vector Plus(Vector a, Vector b)
    Parameters
    Type Name Description
    Vector a
    Vector b
    Returns
    Type Description
    Vector

    a+b

    Plus(Double, Double)

    Returns the sum of the two arguments: (a + b).

    Declaration
    [ParameterNames(new string[]{"Sum", "A", "B"})]
    public static double Plus(double a, double b)
    Parameters
    Type Name Description
    Double a
    Double b
    Returns
    Type Description
    Double

    a+b

    Plus(Int32, Int32)

    Returns the sum of the two arguments: (a + b).

    Declaration
    [ParameterNames(new string[]{"Sum", "A", "B"})]
    public static int Plus(int a, int b)
    Parameters
    Type Name Description
    Int32 a
    Int32 b
    Returns
    Type Description
    Int32

    a+b

    Poisson(Double)

    Sample from a Poisson distribution with a specified mean

    Declaration
    [ParameterNames(new string[]{"sample", "mean"})]
    public static int Poisson(double mean)
    Parameters
    Type Name Description
    Double mean

    The mean of the Poisson distribution

    Returns
    Type Description
    Int32

    An integer sample >= 0

    Product(Matrix, Vector)

    Multiply matrix times vector

    Declaration
    public static Vector Product(Matrix a, Vector b)
    Parameters
    Type Name Description
    Matrix a
    Vector b
    Returns
    Type Description
    Vector

    sum_j a[i,j]*b[j]

    Product(PositiveDefiniteMatrix, Double)

    Multiply posdef matrix times scalar

    Declaration
    public static PositiveDefiniteMatrix Product(PositiveDefiniteMatrix a, double b)
    Parameters
    Type Name Description
    PositiveDefiniteMatrix a
    Double b
    Returns
    Type Description
    PositiveDefiniteMatrix

    a[i,j]*b

    Product(Vector, Double)

    Multiply vector times scalar

    Declaration
    public static Vector Product(Vector a, double b)
    Parameters
    Type Name Description
    Vector a
    Double b
    Returns
    Type Description
    Vector

    a[i]*b

    Product(Double, PositiveDefiniteMatrix)

    Multiply scalar times posdef matrix

    Declaration
    public static PositiveDefiniteMatrix Product(double a, PositiveDefiniteMatrix b)
    Parameters
    Type Name Description
    Double a
    PositiveDefiniteMatrix b
    Returns
    Type Description
    PositiveDefiniteMatrix

    a*b[i,j]

    Product(Double, Double)

    Returns the product of the two arguments a * b.

    Declaration
    public static double Product(double a, double b)
    Parameters
    Type Name Description
    Double a
    Double b
    Returns
    Type Description
    Double

    a*b

    Product(Double[,], Vector)

    Multiply matrix times vector

    Declaration
    public static Vector Product(double[, ] a, Vector b)
    Parameters
    Type Name Description
    Double[,] a
    Vector b
    Returns
    Type Description
    Vector

    sum_j a[i,j]*b[j]

    Product(Int32, Int32)

    Returns the product of the two arguments a * b.

    Declaration
    public static int Product(int a, int b)
    Parameters
    Type Name Description
    Int32 a
    Int32 b
    Returns
    Type Description
    Int32

    a*b

    Product_SHG09(Double, Double)

    Returns the product of the two arguments a * b.

    Declaration
    [ParameterNames(new string[]{"Product", "A", "B"})]
    public static double Product_SHG09(double a, double b)
    Parameters
    Type Name Description
    Double a
    Double b
    Returns
    Type Description
    Double

    a*b

    ProductExp(Double, Double)

    Returns the product a * exp(b).

    Declaration
    public static double ProductExp(double a, double b)
    Parameters
    Type Name Description
    Double a
    Double b
    Returns
    Type Description
    Double

    Random<DomainType>(Sampleable<DomainType>)

    Random factor - samples from a given distribution

    Declaration
    public static DomainType Random<DomainType>(Sampleable<DomainType> dist)
    Parameters
    Type Name Description
    Sampleable<DomainType> dist

    Distribution to sample from

    Returns
    Type Description
    DomainType

    Sample

    Type Parameters
    Name Description
    DomainType

    Domain type

    Ratio(Double, Double)

    Returns the ratio of the two arguments a / b.

    Declaration
    public static double Ratio(double a, double b)
    Parameters
    Type Name Description
    Double a
    Double b
    Returns
    Type Description
    Double

    a-b

    Rotate(Double, Double, Double)

    Rotate a 2D vector about the origin

    Declaration
    public static Vector Rotate(double x, double y, double angle)
    Parameters
    Type Name Description
    Double x

    First coordinate of vector

    Double y

    Second coordinate of vector

    Double angle

    Counter-clockwise rotation angle in radians

    Returns
    Type Description
    Vector

    The rotated vector

    Single(String)

    If a given string contains a single character, extracts the character, otherwise fails.

    Declaration
    [ParameterNames(new string[]{"character", "str"})]
    public static char Single(string str)
    Parameters
    Type Name Description
    String str

    The string.

    Returns
    Type Description
    Char

    The extracted character.

    String(Int32, DiscreteChar)

    Samples a string from a uniform distribution over strings of length greater or equal to a given one, with characters restricted to the support of a given distribution.

    Declaration
    [ParameterNames(new string[]{"str", "minLength", "allowedChars"})]
    public static string String(int minLength, DiscreteChar allowedChars)
    Parameters
    Type Name Description
    Int32 minLength

    The minimum length of a string.

    DiscreteChar allowedChars

    The distribution specifying allowed string characters.

    Returns
    Type Description
    String

    The sampled string.

    Remarks

    The method always throws InvalidOperationException since the distribution is improper.

    String(Int32, Int32, DiscreteChar)

    Samples a string from a uniform distribution over strings of length within given bounds, with characters restricted to the support of a given distribution.

    Declaration
    [ParameterNames(new string[]{"str", "minLength", "maxLength", "allowedChars"})]
    public static string String(int minLength, int maxLength, DiscreteChar allowedChars)
    Parameters
    Type Name Description
    Int32 minLength

    The minimum length of a string.

    Int32 maxLength

    The maximum length of a string.

    DiscreteChar allowedChars

    The distribution specifying allowed string characters.

    Returns
    Type Description
    String

    The sampled string.

    StringCapitalized(Int32)

    Samples a string from Capitalized(Int32, Nullable<Int32>, Boolean) with a specified minimum string length.

    Declaration
    [ParameterNames(new string[]{"str", "minLength"})]
    public static string StringCapitalized(int minLength)
    Parameters
    Type Name Description
    Int32 minLength

    The minimum length of a string.

    Returns
    Type Description
    String

    The sampled string.

    Remarks

    The method always throws InvalidOperationException since the distribution is improper.

    StringCapitalized(Int32, Int32)

    Samples a string from Capitalized(Int32, Nullable<Int32>, Boolean) with a specified minimum and maximum string length.

    Declaration
    [ParameterNames(new string[]{"str", "minLength", "maxLength"})]
    public static string StringCapitalized(int minLength, int maxLength)
    Parameters
    Type Name Description
    Int32 minLength

    The minimum length of a string.

    Int32 maxLength

    The maximum length of a string.

    Returns
    Type Description
    String

    The sampled string.

    StringFormat(String, String[])

    Replaces argument placeholders such as {0}, {1} etc with arguments having the corresponding index, similar to what Format(String, Object[]) does.

    Declaration
    [ParameterNames(new string[]{"str", "format", "args"})]
    public static string StringFormat(string format, string[] args)
    Parameters
    Type Name Description
    String format

    The string with argument placeholders.

    String[] args

    The array of arguments.

    Returns
    Type Description
    String

    format with argument placeholders replaced by arguments.

    Remarks

    This method has the following notable differences from Format(String, Object[]):

      Placeholder for each of the arguments must be present in the format string exactly once. No braces are allowed except for those used to specify placeholders.

      StringFromArray(Char[])

      Converts a given character array to a string.

      Declaration
      [ParameterNames(new string[]{"str", "characters"})]
      public static string StringFromArray(char[] characters)
      Parameters
      Type Name Description
      Char[] characters

      The character array to convert.

      Returns
      Type Description
      String

      A string made of characters in the array.

      StringOfLength(Int32, DiscreteChar)

      Samples a string from a uniform distribution over strings of a given length, with characters restricted to the support of a given distribution.

      Declaration
      [ParameterNames(new string[]{"str", "length", "allowedChars"})]
      public static string StringOfLength(int length, DiscreteChar allowedChars)
      Parameters
      Type Name Description
      Int32 length

      The length of a string.

      DiscreteChar allowedChars

      The distribution specifying allowed string characters.

      Returns
      Type Description
      String

      The sampled string.

      Substring(String, Int32, Int32)

      Extracts a substring from a given string.

      Declaration
      [ParameterNames(new string[]{"sub", "str", "start", "length"})]
      public static string Substring(string str, int start, int length)
      Parameters
      Type Name Description
      String str

      The string.

      Int32 start

      The start index of the substring.

      Int32 length

      The length of the substring.

      Returns
      Type Description
      String

      The extracted substring.

      Sum(IList<Vector>)

      Sums the specified list of vectors.

      Declaration
      public static Vector Sum(IList<Vector> array)
      Parameters
      Type Name Description
      IList<Vector> array

      The list of vectors.

      Returns
      Type Description
      Vector

      The sum over all vectors in the array.

      Sum(IList<Double>)

      Sum the numbers in an array.

      Declaration
      public static double Sum(IList<double> array)
      Parameters
      Type Name Description
      IList<Double> array
      Returns
      Type Description
      Double

      sum_i array[i]

      Sum(IList<Int32>)

      Sum the numbers in an array.

      Declaration
      public static int Sum(IList<int> array)
      Parameters
      Type Name Description
      IList<Int32> array
      Returns
      Type Description
      Int32

      sum_i array[i]

      SumExcept(Double[], Int32)

      Sum the numbers in an array, excluding one index.

      Declaration
      public static double SumExcept(double[] array, int index)
      Parameters
      Type Name Description
      Double[] array
      Int32 index
      Returns
      Type Description
      Double

      TruncatedGammaFromShapeAndRate(Double, Double, Double, Double)

      Sample from a Gamma with specified shape and scale

      Declaration
      [ParameterNames(new string[]{"sample", "shape", "rate", "lowerBound", "upperBound"})]
      public static double TruncatedGammaFromShapeAndRate(double shape, double rate, double lowerBound, double upperBound)
      Parameters
      Type Name Description
      Double shape
      Double rate
      Double lowerBound
      Double upperBound
      Returns
      Type Description
      Double

      UniformPlusMinus(Double)

      Generate a real number uniformly between [-upperBound,upperBound]

      Declaration
      [ParameterNames(new string[]{"sample", "upperBound"})]
      public static double UniformPlusMinus(double upperBound)
      Parameters
      Type Name Description
      Double upperBound
      Returns
      Type Description
      Double

      VectorGaussian(Vector, PositiveDefiniteMatrix)

      Sample from a VectorGaussian distribution.

      Declaration
      [ParameterNames(new string[]{"sample", "mean", "precision"})]
      public static Vector VectorGaussian(Vector mean, PositiveDefiniteMatrix precision)
      Parameters
      Type Name Description
      Vector mean

      The mean vector of the distribution.

      PositiveDefiniteMatrix precision

      The precision matrix of the distribution. The variance matrix will be inv(precision).

      Returns
      Type Description
      Vector

      A random real vector.

      In This Article
      Back to top Copyright © .NET Foundation. All rights reserved.