Search Results for

    Show / Hide Table of Contents

    Class DistributionRefArray<T, DomainType>

    A distribution over an array of type DomainType, where each element is independent and has distribution of type T

    Inheritance
    Object
    ArrayBase<T>
    Array<T>
    DistributionArray<T>
    DistributionArray<T, DomainType>
    DistributionRefArray<T, DomainType>
    Implements
    IArray<T>
    IList<T>
    ICollection<T>
    CanSetAllElementsTo<T>
    IReadOnlyList<T>
    IReadOnlyCollection<T>
    IEnumerable<T>
    IEnumerable
    SettableTo<T[]>
    SettableTo<Array<T>>
    ConvertibleToArray
    IDistribution<DomainType[]>
    IDistribution
    ICloneable
    Diffable
    SettableToUniform
    HasPoint<DomainType[]>
    CanGetLogProb<DomainType[]>
    Sampleable<DomainType[]>
    IArrayFactory<T, DistributionRefArray<T, DomainType>>
    SettableTo<DistributionRefArray<T, DomainType>>
    SettableToProduct<DistributionRefArray<T, DomainType>>
    SettableToProduct<DistributionRefArray<T, DomainType>, DistributionRefArray<T, DomainType>>
    SettableToRatio<DistributionRefArray<T, DomainType>>
    SettableToRatio<DistributionRefArray<T, DomainType>, DistributionRefArray<T, DomainType>>
    SettableToPower<DistributionRefArray<T, DomainType>>
    SettableToWeightedSum<DistributionRefArray<T, DomainType>>
    CanGetLogAverageOf<DistributionRefArray<T, DomainType>>
    CanGetLogAverageOfPower<DistributionRefArray<T, DomainType>>
    CanGetAverageLog<DistributionRefArray<T, DomainType>>
    Inherited Members
    DistributionArray<T, DomainType>.Point
    DistributionArray<T, DomainType>.IsPointMass
    DistributionArray<T, DomainType>.GetLogProb(DomainType[])
    DistributionArray<T, DomainType>.Sample()
    DistributionArray<T, DomainType>.Sample(DomainType[])
    DistributionArray<T>.SetToUniform()
    DistributionArray<T>.IsUniform()
    DistributionArray<T>.MaxDiff(Object)
    Array<T>.SetTo(Array<T>)
    Array<T>.ToArray()
    Array<T>.ConvertibleToArray.ToArray()
    Array<T>.ToArray<TOutput>(Converter<T, TOutput>, Array<T>)
    Array<T>.Rank
    Array<T>.GetLength(Int32)
    Array<T>.Equals(Object)
    Array<T>.GetHashCode()
    ArrayBase<T>.array
    ArrayBase<T>.Item[Int32]
    ArrayBase<T>.IndexOf(T)
    ArrayBase<T>.Insert(Int32, T)
    ArrayBase<T>.RemoveAt(Int32)
    ArrayBase<T>.Add(T)
    ArrayBase<T>.Clear()
    ArrayBase<T>.Contains(T)
    ArrayBase<T>.Count
    ArrayBase<T>.IsReadOnly
    ArrayBase<T>.Remove(T)
    ArrayBase<T>.GetEnumerator()
    ArrayBase<T>.IEnumerable.GetEnumerator()
    ArrayBase<T>.ToString()
    ArrayBase<T>.CheckCompatible(IArray<T>)
    ArrayBase<T>.FindIndex(Predicate<T>)
    ArrayBase<T>.ForEach(Action<T>)
    ArrayBase<T>.ForEach<U>(U[], Action<T, U>)
    ArrayBase<T>.ForEach<U, V>(U[], V[], Action<T, U, V>)
    ArrayBase<T>.SetToFunction<U>(U[], Func<U, T>)
    ArrayBase<T>.SetToFunction<U>(ArrayBase<U>, Func<U, T>)
    ArrayBase<T>.SetToFunction<U, V>(ArrayBase<U>, V[], Func<U, V, T>)
    ArrayBase<T>.SetToFunction<U, V, W>(ArrayBase<U>, V[], W[], Func<U, V, W, T>)
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Distributions
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Serializable]
    [Quality(QualityBand.Mature)]
    [DataContract]
    public class DistributionRefArray<T, DomainType> : DistributionArray<T, DomainType>, IArray<T>, IList<T>, ICollection<T>, CanSetAllElementsTo<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, SettableTo<T[]>, SettableTo<Array<T>>, ConvertibleToArray, IDistribution<DomainType[]>, IDistribution, ICloneable, Diffable, SettableToUniform, HasPoint<DomainType[]>, CanGetLogProb<DomainType[]>, Sampleable<DomainType[]>, IArrayFactory<T, DistributionRefArray<T, DomainType>>, SettableTo<DistributionRefArray<T, DomainType>>, SettableToProduct<DistributionRefArray<T, DomainType>>, SettableToProduct<DistributionRefArray<T, DomainType>, DistributionRefArray<T, DomainType>>, SettableToRatio<DistributionRefArray<T, DomainType>>, SettableToRatio<DistributionRefArray<T, DomainType>, DistributionRefArray<T, DomainType>>, SettableToPower<DistributionRefArray<T, DomainType>>, SettableToWeightedSum<DistributionRefArray<T, DomainType>>, CanGetLogAverageOf<DistributionRefArray<T, DomainType>>, CanGetLogAverageOfPower<DistributionRefArray<T, DomainType>>, CanGetAverageLog<DistributionRefArray<T, DomainType>> where T : class, ICloneable, SettableTo<T>, SettableToProduct<T>, SettableToRatio<T>, SettableToPower<T>, SettableToWeightedSum<T>, CanGetLogAverageOf<T>, CanGetLogAverageOfPower<T>, CanGetAverageLog<T>, IDistribution<DomainType>, Sampleable<DomainType>
    Type Parameters
    Name Description
    T

    Distribution type of an element

    DomainType

    Domain type of an element

    Remarks

    This is an extension of DistributionArray that requires T to be a reference type. The SetTo and CopyTo methods are overriden to use cloning instead of assignment.

    Constructors

    DistributionRefArray()

    Parameterless constructor needed for serialization

    Declaration
    protected DistributionRefArray()

    DistributionRefArray(T, Int32)

    Creates a new distribution array given a value and a length

    Declaration
    public DistributionRefArray(T value, int length)
    Parameters
    Type Name Description
    T value
    Int32 length

    DistributionRefArray(T[])

    Creates a new distribution array given an array of distributions

    Declaration
    public DistributionRefArray(T[] array)
    Parameters
    Type Name Description
    T[] array

    DistributionRefArray(Array<T>)

    Copy constructor

    Declaration
    public DistributionRefArray(Array<T> that)
    Parameters
    Type Name Description
    Array<T> that

    DistributionRefArray(Int32)

    Creates a distribution array given a length

    Declaration
    public DistributionRefArray(int length)
    Parameters
    Type Name Description
    Int32 length

    DistributionRefArray(Int32, Func<Int32, T>)

    Create a distribution struct array of a specified length and initial values.

    Declaration
    public DistributionRefArray(int length, Func<int, T> init)
    Parameters
    Type Name Description
    Int32 length
    Func<Int32, T> init

    Function that maps an index to a value.

    Remarks

    The references returned by init are not copied. They are placed directly into the array.

    Methods

    Clone()

    Clones the array and the items in the array.

    Declaration
    public override object Clone()
    Returns
    Type Description
    Object
    Overrides
    Microsoft.ML.Probabilistic.Collections.Array<T>.Clone()

    CopyTo(T[])

    Set the parameters of array[i] to match the marginal distribution of element i, creating a new distribution if array[i] was null

    Declaration
    public override void CopyTo(T[] array)
    Parameters
    Type Name Description
    T[] array

    Array to write into

    Overrides
    Microsoft.ML.Probabilistic.Collections.Array<T>.CopyTo(T[])

    CopyTo(T[], Int32)

    Set the parameters of array[i] to match the marginal distribution of element i, creating a new distribution if array[i] was null, starting at a given index

    Declaration
    public override void CopyTo(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array
    Int32 arrayIndex

    The index to start at

    Overrides
    Microsoft.ML.Probabilistic.Collections.ArrayBase<T>.CopyTo(T[], System.Int32)

    CreateArray(Int32, Func<Int32, T>)

    Declaration
    public DistributionRefArray<T, DomainType> CreateArray(int length, Func<int, T> init)
    Parameters
    Type Name Description
    Int32 length
    Func<Int32, T> init
    Returns
    Type Description
    DistributionRefArray<T, DomainType>

    GetAverageLog(DistributionRefArray<T, DomainType>)

    The expected logarithm of that distribution under this distribution.

    Declaration
    public double GetAverageLog(DistributionRefArray<T, DomainType> that)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> that

    The distribution to take the logarithm of.

    Returns
    Type Description
    Double

    sum_x this.Evaluate(x)*Math.Log(that.Evaluate(x))

    Remarks

    This is also known as the cross entropy. For a DistributionArray, this specializes to: sum_i sum_x this[i].Evaluate(x)*Math.Log(that[i].Evaluate(x)) = sum_i this[i].GetAverageLog(that[i])

    GetLogAverageOf(DistributionRefArray<T, DomainType>)

    The log-probability that two distributions would draw the same sample.

    Declaration
    public double GetLogAverageOf(DistributionRefArray<T, DomainType> that)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> that
    Returns
    Type Description
    Double

    Math.Log(sum_x this.Evaluate(x)*that.Evaluate(x))

    Remarks

    This can be considered a type of inner product between distributions. Another name might be "LogAverage" to go with "GetAverageLog". For a DistributionArray, this specializes to: sum_i Math.Log(sum_x this[i].Evaluate(x)*that[i].Evaluate(x)) = sum_i this[i].GetLogAverageOf(that[i])

    GetLogAverageOfPower(DistributionRefArray<T, DomainType>, Double)

    Get the integral of this distribution times another distribution raised to a power.

    Declaration
    public double GetLogAverageOfPower(DistributionRefArray<T, DomainType> that, double power)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> that
    Double power
    Returns
    Type Description
    Double

    InitializeTo(T)

    Initialise all the values in this array to clones of the given value

    Declaration
    protected void InitializeTo(T value)
    Parameters
    Type Name Description
    T value

    InitializeTo(T[])

    Initialise the elements of this distribution array to clones of the given distributions

    Declaration
    protected void InitializeTo(T[] array)
    Parameters
    Type Name Description
    T[] array
    Remarks

    Given array and this array must be the same length

    Sample(DomainType[])

    Get a sample from the distribution

    Declaration
    public override DomainType[] Sample(DomainType[] result)
    Parameters
    Type Name Description
    DomainType[] result

    Where to put the results

    Returns
    Type Description
    DomainType[]

    A sample

    Overrides
    Microsoft.ML.Probabilistic.Distributions.DistributionArray<T, DomainType>.Sample(DomainType[])

    SetAllElementsTo(T)

    Set the parameters of this distribution so that all marginals equal the given distribution (by value)

    Declaration
    public override void SetAllElementsTo(T value)
    Parameters
    Type Name Description
    T value
    Overrides
    Microsoft.ML.Probabilistic.Collections.ArrayBase<T>.SetAllElementsTo(T)

    SetItemsOf(T[])

    Set the parameters of array[i] to match the marginal distribution of element i

    Declaration
    protected void SetItemsOf(T[] array)
    Parameters
    Type Name Description
    T[] array

    SetItemsOf(T[], Int32)

    Set the parameters of array[i] to match the marginal distribution of element i, starting at a given index

    Declaration
    protected void SetItemsOf(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array
    Int32 arrayIndex

    The index to start at

    SetTo(T[])

    Set the parameters of this distribution so that the marginals match the given distributions (by value)

    Declaration
    public override void SetTo(T[] array)
    Parameters
    Type Name Description
    T[] array
    Overrides
    Microsoft.ML.Probabilistic.Collections.Array<T>.SetTo(T[])
    Remarks

    Given array and this array must be the same length.

    SetTo(DistributionRefArray<T, DomainType>)

    Set the parameters of this distribution to match those of the given distribution (by value)

    Declaration
    public void SetTo(DistributionRefArray<T, DomainType> that)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> that

    SetToPower(DistributionRefArray<T, DomainType>, Double)

    Set the parameters to represent the power of a source distribution to some exponent

    Declaration
    public void SetToPower(DistributionRefArray<T, DomainType> a, double exponent)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> a

    The source distribution array

    Double exponent

    The exponent

    SetToProduct(DistributionRefArray<T, DomainType>, DistributionRefArray<T, DomainType>)

    Set the parameters to represent the product of two distributions

    Declaration
    public void SetToProduct(DistributionRefArray<T, DomainType> a, DistributionRefArray<T, DomainType> b)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> a

    The first distribution array

    DistributionRefArray<T, DomainType> b

    The second distribution array

    SetToRatio(DistributionRefArray<T, DomainType>, DistributionRefArray<T, DomainType>, Boolean)

    Set the parameters to represent the ratio of two distributions

    Declaration
    public void SetToRatio(DistributionRefArray<T, DomainType> numerator, DistributionRefArray<T, DomainType> denominator, bool forceProper)
    Parameters
    Type Name Description
    DistributionRefArray<T, DomainType> numerator

    The numerator distribution array

    DistributionRefArray<T, DomainType> denominator

    The denominator distribution array

    Boolean forceProper

    Argument passed to T.SetToRatio

    SetToSum(Double, DistributionRefArray<T, DomainType>, Double, DistributionRefArray<T, DomainType>)

    Set the parameters to match the moments of a mixture of two distributions

    Declaration
    public void SetToSum(double weight1, DistributionRefArray<T, DomainType> a, double weight2, DistributionRefArray<T, DomainType> b)
    Parameters
    Type Name Description
    Double weight1

    The first weight

    DistributionRefArray<T, DomainType> a

    The first distribution array

    Double weight2

    The second weight

    DistributionRefArray<T, DomainType> b

    The second distribution array

    Implements

    IArray<T>
    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    CanSetAllElementsTo<T>
    System.Collections.Generic.IReadOnlyList<T>
    System.Collections.Generic.IReadOnlyCollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    SettableTo<T>
    SettableTo<T>
    ConvertibleToArray
    IDistribution<T>
    IDistribution
    System.ICloneable
    Diffable
    SettableToUniform
    HasPoint<T>
    CanGetLogProb<T>
    Sampleable<T>
    IArrayFactory<ItemType, ArrayType>
    SettableTo<T>
    SettableToProduct<T>
    SettableToProduct<T, U>
    SettableToRatio<T>
    SettableToRatio<T, U>
    SettableToPower<T>
    SettableToWeightedSum<T>
    CanGetLogAverageOf<T>
    CanGetLogAverageOfPower<T>
    CanGetAverageLog<T>

    Extension Methods

    CollectionExtensions.AddRange<T>(ICollection<T>, IEnumerable<T>)
    CollectionExtensions.ContainsAll<T>(ICollection<T>, IEnumerable<T>)
    CollectionExtensions.ContainsAny<T>(ICollection<T>, IEnumerable<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<Int32, T>)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<Int32, T>)
    EnumerableExtensions.Sum<TSource>(IEnumerable<TSource>, Func<TSource, UInt32>)
    EnumerableExtensions.Sum<TSource>(IEnumerable<TSource>, Func<TSource, UInt64>)
    EnumerableExtensions.ValueEquals<T>(IEnumerable<T>, IEnumerable<T>)
    EnumerableExtensions.IndexOf<T>(IEnumerable<T>, T)
    EnumerableExtensions.IndexOf<T>(IEnumerable, T)
    EnumerableExtensions.FindIndex<T>(IEnumerable<T>, Predicate<T>)
    EnumerableExtensions.FindIndex<T>(IEnumerable, Predicate<T>)
    EnumerableExtensions.FindAllIndex<T>(IEnumerable<T>, Predicate<T>)
    EnumerableExtensions.IndexOfAll<T>(IEnumerable<T>, T)
    EnumerableExtensions.Skip<T>(IEnumerable<T>, Int32, out List<T>)
    EnumerableExtensions.CopyTo<T>(IEnumerable<T>, T[], Int32)
    EnumerableExtensions.ToReadOnlyList<T>(IEnumerable<T>)
    IEnumerableExensions.EnumerableReduce<T, TRes>(IEnumerable<T>, TRes, Func<TRes, T, TRes>, Func<TRes, T, Int32, TRes>)
    IEnumerableExensions.EnumerableSum<T>(IEnumerable<T>, Func<T, Double>)
    IEnumerableExensions.ListZip<TFirst, TSecond, TResult>(IList<TFirst>, IEnumerable<TSecond>, Func<TFirst, TSecond, TResult>)
    IEnumerableExensions.ListZip<TFirst, TSecond, TThird, TResult>(IList<TFirst>, IEnumerable<TSecond>, IEnumerable<TThird>, Func<TFirst, TSecond, TThird, TResult>)
    IEnumerableExensions.ListZip<TFirst, TSecond, TThird, TFourth, TResult>(IList<TFirst>, IList<TSecond>, IList<TThird>, IList<TFourth>, Func<TFirst, TSecond, TThird, TFourth, TResult>)
    IListExtensions.IsSparse<T>(IList<T>)
    IListExtensions.ListSelect<T, T2>(IList<T>, Func<T, T2>)
    IListExtensions.ListReduce<T, TRes>(IList<T>, TRes, Func<TRes, T, TRes>)
    IListExtensions.ListReduce<T, T2, TRes>(IList<T>, IEnumerable<T2>, TRes, Func<TRes, T, T2, TRes>)
    IListExtensions.SetTo<T>(IList<T>, IEnumerable<T>)
    IListExtensions.AsReadOnly<T>(IList<T>)
    ReadOnlyArray.ToReadOnlyArray<T>(IEnumerable<T>)
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.