Search Results for

    Show / Hide Table of Contents

    Class SparseDistributionList<TDist, TDomain, TThis>

    Abstract base class for a homogeneous sparse list of distributions. The class supports an approximation tolerance which allows elements close to the common value to be automatically reset to the common value. The list implements the interfaces which allow these distributions to participate in message passing.

    Inheritance
    Object
    SparseList<TDist>
    ApproximateSparseList<TDist>
    SparseDistributionList<TDist, TDomain, TThis>
    SparseBernoulliList
    SparseBetaList
    SparseGammaList
    SparseGaussianList
    Implements
    ISparseList<TDist>
    ISparseEnumerable<TDist>
    IList<TDist>
    ICollection<TDist>
    IEnumerable<TDist>
    IList
    ICollection
    IEnumerable
    IDistribution<ISparseList<TDomain>>
    IDistribution
    ICloneable
    Diffable
    SettableToUniform
    HasPoint<ISparseList<TDomain>>
    CanGetLogProb<ISparseList<TDomain>>
    Sampleable<ISparseList<TDomain>>
    SettableTo<TThis>
    SettableToProduct<TThis>
    SettableToProduct<TThis, TThis>
    SettableToPower<TThis>
    SettableToRatio<TThis>
    SettableToRatio<TThis, TThis>
    SettableToWeightedSum<TThis>
    CanGetLogAverageOf<TThis>
    CanGetLogAverageOfPower<TThis>
    CanGetAverageLog<TThis>
    CanGetMean<ISparseList<Double>>
    CanGetVariance<ISparseList<Double>>
    Inherited Members
    ApproximateSparseList<TDist>.DefaultTolerance
    ApproximateSparseList<TDist>.Tolerance
    ApproximateSparseList<TDist>.Item[Int32]
    ApproximateSparseList<TDist>.SetTo(ApproximateSparseList<TDist>)
    ApproximateSparseList<TDist>.SetTo(IList<TDist>, TDist)
    ApproximateSparseList<TDist>.Equals(Object)
    ApproximateSparseList<TDist>.GetHashCode()
    ApproximateSparseList<TDist>.SetToFunction<T2>(SparseList<T2>, Func<T2, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T2>(ISparseEnumerable<T2>, Func<T2, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T2>(IEnumerable<T2>, Func<T2, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2>(SparseList<T1>, SparseList<T2>, Func<T1, T2, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2>(ISparseEnumerable<T1>, ISparseEnumerable<T2>, Func<T1, T2, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2>(IEnumerable<T1>, IEnumerable<T2>, Func<T1, T2, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2, T3>(ISparseEnumerable<T1>, ISparseEnumerable<T2>, ISparseEnumerable<T3>, Func<T1, T2, T3, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2, T3>(IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, Func<T1, T2, T3, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2, T3, T4>(ISparseList<T1>, ISparseList<T2>, ISparseList<T3>, ISparseList<T4>, Func<T1, T2, T3, T4, TDist>)
    ApproximateSparseList<TDist>.SetToFunction<T1, T2, T3, T4>(IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>, Func<T1, T2, T3, T4, TDist>)
    ApproximateSparseList<TDist>.SetToFunctionInPlace<T1>(SparseList<T1>, Func<TDist, T1, TDist>)
    SparseList<TDist>.Sparsity
    SparseList<TDist>.SparseValues
    SparseList<TDist>.CommonValue
    SparseList<TDist>.Count
    SparseList<TDist>.SparseCount
    SparseList<TDist>.Copy(IList<TDist>)
    SparseList<TDist>.GetSparseIndex(Int32)
    SparseList<TDist>.HasCommonElements
    SparseList<TDist>.GetFirstCommonIndex()
    SparseList<TDist>.GetEnumerator()
    SparseList<TDist>.IEnumerable.GetEnumerator()
    SparseList<TDist>.SetAllElementsTo(TDist)
    SparseList<TDist>.SetTo(IList<TDist>)
    SparseList<TDist>.CheckCompatible<T2>(IList<T2>, String)
    SparseList<TDist>.SetTo(SparseList<TDist>)
    SparseList<TDist>.SetTo(IEnumerable<TDist>)
    SparseList<TDist>.ICloneable.Clone()
    SparseList<TDist>.EqualsAll(TDist)
    SparseList<TDist>.All(Converter<TDist, Boolean>)
    SparseList<TDist>.Any(Converter<TDist, Boolean>)
    SparseList<TDist>.IndexOfAll(Converter<TDist, Boolean>)
    SparseList<TDist>.Reduce<TRes>(TRes, Func<TRes, TDist, TRes>)
    SparseList<TDist>.Reduce<TRes>(TRes, Func<TRes, TDist, TRes>, Func<TRes, TDist, Int32, TRes>)
    SparseList<TDist>.Reduce<TRes, T1>(TRes, ISparseEnumerable<T1>, Func<TRes, TDist, T1, TRes>, Func<TRes, TDist, T1, Int32, TRes>)
    SparseList<TDist>.Reduce<TRes, T1, T2>(TRes, ISparseEnumerable<T1>, ISparseEnumerable<T2>, Func<TRes, TDist, T1, T2, TRes>, Func<TRes, TDist, T1, T2, Int32, TRes>)
    SparseList<TDist>.Reduce<TRes, T2>(TRes, IEnumerable<T2>, Func<TRes, TDist, T2, TRes>)
    SparseList<TDist>.Reduce<TRes, T1, T2>(TRes, IList<T1>, IList<T2>, Func<TRes, TDist, T1, T2, TRes>)
    SparseList<TDist>.Contains(TDist)
    SparseList<TDist>.IndexOf(TDist)
    SparseList<TDist>.IsReadOnly
    SparseList<TDist>.CopyTo(TDist[], Int32)
    SparseList<TDist>.Insert(Int32, TDist)
    SparseList<TDist>.RemoveAt(Int32)
    SparseList<TDist>.Add(TDist)
    SparseList<TDist>.Clear()
    SparseList<TDist>.Remove(TDist)
    SparseList<TDist>.IList.Add(Object)
    SparseList<TDist>.IList.Contains(Object)
    SparseList<TDist>.IList.IndexOf(Object)
    SparseList<TDist>.IList.Insert(Int32, Object)
    SparseList<TDist>.IList.IsFixedSize
    SparseList<TDist>.IList.Remove(Object)
    SparseList<TDist>.IList.Item[Int32]
    SparseList<TDist>.ICollection.CopyTo(Array, Int32)
    SparseList<TDist>.ICollection.IsSynchronized
    SparseList<TDist>.ICollection.SyncRoot
    SparseList<TDist>.ToArray<T2>(IList<T2>)
    SparseList<TDist>.ToString()
    SparseList<TDist>.ToString(String)
    SparseList<TDist>.ToArray()
    SparseList<TDist>.ToList()
    SparseList<TDist>.GetSparseEnumerator()
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Distributions
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Serializable]
    [DataContract]
    public abstract class SparseDistributionList<TDist, TDomain, TThis> : ApproximateSparseList<TDist>, ISparseList<TDist>, ISparseEnumerable<TDist>, IList<TDist>, ICollection<TDist>, IEnumerable<TDist>, IList, ICollection, IEnumerable, IDistribution<ISparseList<TDomain>>, IDistribution, ICloneable, Diffable, SettableToUniform, HasPoint<ISparseList<TDomain>>, CanGetLogProb<ISparseList<TDomain>>, Sampleable<ISparseList<TDomain>>, SettableTo<TThis>, SettableToProduct<TThis>, SettableToProduct<TThis, TThis>, SettableToPower<TThis>, SettableToRatio<TThis>, SettableToRatio<TThis, TThis>, SettableToWeightedSum<TThis>, CanGetLogAverageOf<TThis>, CanGetLogAverageOfPower<TThis>, CanGetAverageLog<TThis>, CanGetMean<ISparseList<double>>, CanGetVariance<ISparseList<double>> where TDist : struct, SettableToUniform, Diffable, Sampleable<TDomain>, SettableToProduct<TDist>, SettableToRatio<TDist>, SettableToPower<TDist>, SettableToWeightedSum<TDist>, CanGetLogAverageOf<TDist>, CanGetAverageLog<TDist>, CanGetLogAverageOfPower<TDist>, CanGetMean<double>, CanGetVariance<double>, IDistribution<TDomain> where TThis : SparseDistributionList<TDist, TDomain, TThis>, new()
    Type Parameters
    Name Description
    TDist

    The distribution type for the elements of the sparse list.

    TDomain

    The domain type for the distribution elements.

    TThis

    The type of a specialized class derived from this class.

    Properties

    Dimension

    Gets the dimension of the sparse distribution list.

    Declaration
    public int Dimension { get; }
    Property Value
    Type Description
    Int32

    IsPointMass

    Gets a value indicating whether the instance is a point mass.

    Declaration
    [IgnoreDataMember]
    public bool IsPointMass { get; }
    Property Value
    Type Description
    Boolean

    True if all elements of the list are point masses, false otherwise.

    Point

    Gets or sets the instance as a point mass.

    Declaration
    [IgnoreDataMember]
    public ISparseList<TDomain> Point { get; set; }
    Property Value
    Type Description
    ISparseList<TDomain>

    Methods

    Clone()

    Clones this SparseDistributionList<TDist, TDomain, TThis>.

    Declaration
    public object Clone()
    Returns
    Type Description
    Object

    The clone returned as an Object.

    Constant(Int32, TDist)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class with the specified number of elements all of which are set to the specified value.

    Declaration
    public static TThis Constant(int size, TDist commonValue)
    Parameters
    Type Name Description
    Int32 size

    The size of the list.

    TDist commonValue

    The common value.

    Returns
    Type Description
    TThis

    The instance.

    Constant(Int32, TDist, Double)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class with the specified number of elements all of which are set to the specified value.

    Declaration
    public static TThis Constant(int size, TDist commonValue, double tolerance)
    Parameters
    Type Name Description
    Int32 size

    The size of the list.

    TDist commonValue

    The common value.

    Double tolerance

    The tolerance for the approximation.

    Returns
    Type Description
    TThis

    The new instance.

    FromSize(Int32)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class with the specified number of elements all of which are set to uniform.

    Declaration
    public static TThis FromSize(int size)
    Parameters
    Type Name Description
    Int32 size

    The size of the list.

    Returns
    Type Description
    TThis

    The new instance.

    FromSize(Int32, Double)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class with the specified number of elements all of which are set to uniform.

    Declaration
    public static TThis FromSize(int size, double tolerance)
    Parameters
    Type Name Description
    Int32 size

    The size of the list.

    Double tolerance

    The tolerance for the approximation.

    Returns
    Type Description
    TThis

    The new instance.

    FromSparseList(ISparseList<TDist>)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class from a sparse list of distributions.

    Declaration
    public static TThis FromSparseList(ISparseList<TDist> distributions)
    Parameters
    Type Name Description
    ISparseList<TDist> distributions

    The sparse list of distributions.

    Returns
    Type Description
    TThis

    The new instance.

    FromSparseList(ISparseList<TDist>, Double)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class from a sparse list of distributions.

    Declaration
    public static TThis FromSparseList(ISparseList<TDist> distributions, double tolerance)
    Parameters
    Type Name Description
    ISparseList<TDist> distributions

    The sparse list of distributions.

    Double tolerance

    The tolerance.

    Returns
    Type Description
    TThis

    The new instance.

    FromSparseValues(Int32, TDist, List<ValueAtIndex<TDist>>)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is so MUST be sorted by index and must not be modified externally after being passed in.

    Declaration
    public static TThis FromSparseValues(int size, TDist commonValue, List<ValueAtIndex<TDist>> sortedSparseValues)
    Parameters
    Type Name Description
    Int32 size

    The size of the list.

    TDist commonValue

    The common value.

    List<ValueAtIndex<TDist>> sortedSparseValues

    The sorted list of non-common values.

    Returns
    Type Description
    TThis

    The new instance.

    FromSparseValues(Int32, TDist, List<ValueAtIndex<TDist>>, Double)

    Returns a new instance of the SparseDistributionList<TDist, TDomain, TThis> class of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is, so MUST be sorted by index and must not be modified externally after being passed in.

    Declaration
    [Construction(new string[]{"Count", "CommonValue", "SparseValues", "Tolerance"})]
    public static TThis FromSparseValues(int size, TDist commonValue, List<ValueAtIndex<TDist>> sortedSparseValues, double tolerance)
    Parameters
    Type Name Description
    Int32 size

    The size of the list.

    TDist commonValue

    The common value.

    List<ValueAtIndex<TDist>> sortedSparseValues

    The sorted list of non-common values.

    Double tolerance

    The tolerance for the approximation.

    Returns
    Type Description
    TThis

    The new instance.

    GetAverageLog(TThis)

    Returns the expected logarithm of that sparse distribution list under this sparse distribution list.

    Declaration
    public double GetAverageLog(TThis that)
    Parameters
    Type Name Description
    TThis that

    The other distribution.

    Returns
    Type Description
    Double

    The expected logarithm of the other distribution.

    GetLogAverageOf(TThis)

    Returns the log probability that this distribution and another draw the same sample.

    Declaration
    public double GetLogAverageOf(TThis that)
    Parameters
    Type Name Description
    TThis that

    The other distribution.

    Returns
    Type Description
    Double

    The log probability that this distribution and another draw the same sample.

    GetLogAverageOfPower(TThis, Double)

    Returns the log of the integral of the product of this sparse distribution list and another sparse distribution list raised to a power.

    Declaration
    public double GetLogAverageOfPower(TThis that, double exponent)
    Parameters
    Type Name Description
    TThis that

    The other distribution.

    Double exponent

    The exponent.

    Returns
    Type Description
    Double

    The log average of the power of the second distribution.

    GetLogProb(ISparseList<TDomain>)

    Evaluates the log of the density function.

    Declaration
    public double GetLogProb(ISparseList<TDomain> value)
    Parameters
    Type Name Description
    ISparseList<TDomain> value

    The point at which to evaluate the density.

    Returns
    Type Description
    Double

    The log probability of the given value>.

    GetMean()

    Gets the mean as a sparse list.

    Declaration
    public ISparseList<double> GetMean()
    Returns
    Type Description
    ISparseList<Double>

    The mean of this distribution.

    GetVariance()

    Gets the variance as a sparse list.

    Declaration
    public ISparseList<double> GetVariance()
    Returns
    Type Description
    ISparseList<Double>

    The variance of this distribution.

    IsUniform()

    Asks whether this sparse distribution list is uniform.

    Declaration
    public bool IsUniform()
    Returns
    Type Description
    Boolean

    True if all elements of the list are uniform, false otherwise.

    MaxDiff(Object)

    Returns the maximum difference between the parameters of this sparse distribution list and another.

    Declaration
    public double MaxDiff(object thatd)
    Parameters
    Type Name Description
    Object thatd

    The other sparse distribution list.

    Returns
    Type Description
    Double

    The maximum difference.

    Remarks

    a.MaxDiff(b) == b.MaxDiff(a).

    Sample()

    Samples from this sparse distribution list.

    Declaration
    public ISparseList<TDomain> Sample()
    Returns
    Type Description
    ISparseList<TDomain>

    A sample from this distribution.

    Remarks

    This method is inefficient in that the result will be dense even though the return type is sparse.

    Sample(ISparseList<TDomain>)

    Samples from this sparse distribution list.

    Declaration
    public ISparseList<TDomain> Sample(ISparseList<TDomain> result)
    Parameters
    Type Name Description
    ISparseList<TDomain> result

    Where to put the result.

    Returns
    Type Description
    ISparseList<TDomain>

    A sample from this distribution.

    Remarks

    This method is inefficient in that the result will be dense even though the return type is sparse.

    SetTo(TThis)

    Sets this sparse distribution list to another sparse distribution list.

    Declaration
    public void SetTo(TThis value)
    Parameters
    Type Name Description
    TThis value

    The other sparse distribution list.

    SetToPower(TThis, Double)

    Sets this sparse distribution list to the power of another sparse distribution list.

    Declaration
    public void SetToPower(TThis value, double exponent)
    Parameters
    Type Name Description
    TThis value

    The value.

    Double exponent

    The exponent.

    SetToProduct(TThis, TThis)

    Sets this sparse distribution list to the product of two other sparse distribution lists.

    Declaration
    public void SetToProduct(TThis a, TThis b)
    Parameters
    Type Name Description
    TThis a

    Left hand side.

    TThis b

    Right hand side.

    SetToRatio(TThis, TThis, Boolean)

    Sets this sparse distribution list to the ratio of two other sparse Gaussian lists.

    Declaration
    public void SetToRatio(TThis numerator, TThis denominator, bool forceProper = false)
    Parameters
    Type Name Description
    TThis numerator

    The numerator.

    TThis denominator

    The denominator.

    Boolean forceProper

    Whether to force the result to be proper.

    SetToSum(Double, TThis, Double, TThis)

    Creates a sparse distribution list to the weighted sums of the elements of two other sparse distribution lists.

    Declaration
    public void SetToSum(double weight1, TThis value1, double weight2, TThis value2)
    Parameters
    Type Name Description
    Double weight1

    The first weight.

    TThis value1

    The first sparse distribution list.

    Double weight2

    The second weight.

    TThis value2

    The second sparse distribution list.

    SetToUniform()

    Sets this sparse distribution list to be a uniform distribution.

    Declaration
    public void SetToUniform()

    Implements

    ISparseList<T>
    ISparseEnumerable<T>
    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.IEnumerable
    IDistribution<T>
    IDistribution
    System.ICloneable
    Diffable
    SettableToUniform
    HasPoint<T>
    CanGetLogProb<T>
    Sampleable<T>
    SettableTo<T>
    SettableToProduct<T>
    SettableToProduct<T, U>
    SettableToPower<T>
    SettableToRatio<T>
    SettableToRatio<T, U>
    SettableToWeightedSum<T>
    CanGetLogAverageOf<T>
    CanGetLogAverageOfPower<T>
    CanGetAverageLog<T>
    CanGetMean<MeanType>
    CanGetVariance<VarType>

    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.