Search Results for

    Show / Hide Table of Contents

    Struct TruncatedGamma

    A distribution over real numbers between an upper and lower bound. If LowerBound=0 and UpperBound=Inf, it reduces to an ordinary Gamma distribution.

    Implements
    IDistribution<Double>
    IDistribution
    ICloneable
    HasPoint<Double>
    CanGetLogProb<Double>
    SettableTo<TruncatedGamma>
    Diffable
    SettableToProduct<TruncatedGamma>
    SettableToProduct<TruncatedGamma, TruncatedGamma>
    SettableToUniform
    SettableToRatio<TruncatedGamma>
    SettableToRatio<TruncatedGamma, TruncatedGamma>
    SettableToPower<TruncatedGamma>
    Sampleable<Double>
    SettableToWeightedSum<TruncatedGamma>
    CanGetMean<Double>
    CanGetVariance<Double>
    CanGetMeanAndVarianceOut<Double, Double>
    CanGetLogNormalizer
    CanGetLogAverageOf<TruncatedGamma>
    CanGetLogAverageOfPower<TruncatedGamma>
    CanGetAverageLog<TruncatedGamma>
    CanGetMode<Double>
    CanGetProbLessThan<Double>
    CanGetQuantile<Double>
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Distributions
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Serializable]
    [DataContract]
    [Quality(QualityBand.Preview)]
    public struct TruncatedGamma : IDistribution<double>, IDistribution, ICloneable, HasPoint<double>, CanGetLogProb<double>, SettableTo<TruncatedGamma>, Diffable, SettableToProduct<TruncatedGamma>, SettableToProduct<TruncatedGamma, TruncatedGamma>, SettableToUniform, SettableToRatio<TruncatedGamma>, SettableToRatio<TruncatedGamma, TruncatedGamma>, SettableToPower<TruncatedGamma>, Sampleable<double>, SettableToWeightedSum<TruncatedGamma>, CanGetMean<double>, CanGetVariance<double>, CanGetMeanAndVarianceOut<double, double>, CanGetLogNormalizer, CanGetLogAverageOf<TruncatedGamma>, CanGetLogAverageOfPower<TruncatedGamma>, CanGetAverageLog<TruncatedGamma>, CanGetMode<double>, CanGetProbLessThan<double>, CanGetQuantile<double>
    Remarks

    The distribution is parameterized by a Gamma and two real numbers (LowerBound, UpperBound). Between the bounds, the density is proportional to the Gamma. Outside of the bounds, the density is zero.

    Constructors

    TruncatedGamma(Gamma)

    Create a truncated Gamma equivalent to a Gamma, i.e. with no truncation.

    Declaration
    public TruncatedGamma(Gamma that)
    Parameters
    Type Name Description
    Gamma that

    TruncatedGamma(Gamma, Double, Double)

    Create a truncated Gamma from a Gamma and bounds

    Declaration
    [Construction(new string[]{"Gamma", "LowerBound", "UpperBound"})]
    public TruncatedGamma(Gamma Gamma, double lowerBound, double upperBound)
    Parameters
    Type Name Description
    Gamma Gamma
    Double lowerBound
    Double upperBound

    TruncatedGamma(TruncatedGamma)

    Create a new TruncatedGamma distribution equal to that

    Declaration
    public TruncatedGamma(TruncatedGamma that)
    Parameters
    Type Name Description
    TruncatedGamma that

    TruncatedGamma(Double, Double, Double, Double)

    Create a truncated Gamma from untruncated (shape, scale) and bounds

    Declaration
    public TruncatedGamma(double shape, double scale, double lowerBound, double upperBound)
    Parameters
    Type Name Description
    Double shape
    Double scale
    Double lowerBound
    Double upperBound

    Fields

    Gamma

    Untruncated Gamma

    Declaration
    [DataMember]
    public Gamma Gamma
    Field Value
    Type Description
    Gamma

    LowerBound

    Lower bound

    Declaration
    [DataMember]
    public double LowerBound
    Field Value
    Type Description
    Double

    UpperBound

    Upper bound

    Declaration
    [DataMember]
    public double UpperBound
    Field Value
    Type Description
    Double

    Properties

    IsPointMass

    True if the distribution is a point mass.

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

    Point

    Set this distribution to a point mass, or get its location

    Declaration
    [IgnoreDataMember]
    public double Point { get; set; }
    Property Value
    Type Description
    Double

    Methods

    Clone()

    Make a deep copy of this distribution.

    Declaration
    public object Clone()
    Returns
    Type Description
    Object

    Equals(Object)

    True if this distribution has the same parameters as that

    Declaration
    public override bool Equals(object thatd)
    Parameters
    Type Name Description
    Object thatd

    The instance to compare to

    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    FromGamma(Gamma)

    Create a truncated Gamma equivalent to a Gamma, i.e. with no truncation.

    Declaration
    public static TruncatedGamma FromGamma(Gamma Gamma)
    Parameters
    Type Name Description
    Gamma Gamma
    Returns
    Type Description
    TruncatedGamma

    GammaProbBetween(Double, Double, Double, Double, Boolean)

    Computes GammaLower(a, ru) - GammaLower(a, rl) to high accuracy.

    Declaration
    public static double GammaProbBetween(double shape, double rate, double lowerBound, double upperBound, bool regularized = true)
    Parameters
    Type Name Description
    Double shape
    Double rate
    Double lowerBound
    Double upperBound
    Boolean regularized
    Returns
    Type Description
    Double

    GammaUpperRatio(Double, Double, Boolean)

    Computes GammaUpper(s,x)/(x^(s-1)*exp(-x)) - 1 to high accuracy

    Declaration
    public static double GammaUpperRatio(double s, double x, bool regularized = true)
    Parameters
    Type Name Description
    Double s
    Double x

    A real number gt;= 45 and gt; s/0.99

    Boolean regularized
    Returns
    Type Description
    Double

    GetAverageLog(TruncatedGamma)

    Get the average logarithm of that distribution under this distribution, i.e. int this(x) log( that(x) ) dx

    Declaration
    public double GetAverageLog(TruncatedGamma that)
    Parameters
    Type Name Description
    TruncatedGamma that
    Returns
    Type Description
    Double

    GetHashCode()

    A hash of the distribution parameter values

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    GetLogAverageOf(TruncatedGamma)

    Get the logarithm of the average value of that distribution under this distribution, i.e. log(int this(x) that(x) dx)

    Declaration
    public double GetLogAverageOf(TruncatedGamma that)
    Parameters
    Type Name Description
    TruncatedGamma that
    Returns
    Type Description
    Double

    GetLogAverageOfPower(TruncatedGamma, Double)

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

    Declaration
    public double GetLogAverageOfPower(TruncatedGamma that, double power)
    Parameters
    Type Name Description
    TruncatedGamma that
    Double power
    Returns
    Type Description
    Double

    GetLogNormalizer()

    Gets the log of the normalizer for the truncated Gamma density function

    Declaration
    public double GetLogNormalizer()
    Returns
    Type Description
    Double

    GetLogProb(Double)

    Get the log probability density at value.

    Declaration
    public double GetLogProb(double value)
    Parameters
    Type Name Description
    Double value
    Returns
    Type Description
    Double

    GetMean()

    Returns the mean (first moment) of the distribution

    Declaration
    public double GetMean()
    Returns
    Type Description
    Double

    GetMeanAndVariance(out Double, out Double)

    Get the mean and variance after truncation.

    Declaration
    public void GetMeanAndVariance(out double mean, out double variance)
    Parameters
    Type Name Description
    Double mean
    Double variance

    GetMeanLog()

    Gets E[log(x)] after truncation.

    Declaration
    public double GetMeanLog()
    Returns
    Type Description
    Double

    GetMeanPower(Double)

    Computes E[x^power]

    Declaration
    public double GetMeanPower(double power)
    Parameters
    Type Name Description
    Double power
    Returns
    Type Description
    Double

    GetMode()

    Get the mode (highest density point) of this distribution

    Declaration
    public double GetMode()
    Returns
    Type Description
    Double

    GetNormalizer()

    Gets the normalizer for the truncated Gamma density function

    Declaration
    public double GetNormalizer()
    Returns
    Type Description
    Double

    GetProbBetween(Double, Double)

    Returns the probability mass in an interval.

    Declaration
    public double GetProbBetween(double lowerBound, double upperBound)
    Parameters
    Type Name Description
    Double lowerBound
    Double upperBound
    Returns
    Type Description
    Double

    A number between 0 and 1, inclusive.

    GetProbLessThan(Double)

    Returns the probability of drawing a sample less than x.

    Declaration
    public double GetProbLessThan(double x)
    Parameters
    Type Name Description
    Double x
    Returns
    Type Description
    Double

    A real number in [0,1].

    GetQuantile(Gamma, Double, Double, Double)

    Declaration
    public static double GetQuantile(Gamma gamma, double lowerBound, double upperBound, double probability)
    Parameters
    Type Name Description
    Gamma gamma
    Double lowerBound
    Double upperBound
    Double probability
    Returns
    Type Description
    Double

    GetQuantile(Double)

    Returns the largest value x such that GetProbLessThan(x) <= probability.

    Declaration
    public double GetQuantile(double probability)
    Parameters
    Type Name Description
    Double probability

    A real number in [0,1].

    Returns
    Type Description
    Double

    A number

    GetVariance()

    Get the variance of this distribution

    Declaration
    public double GetVariance()
    Returns
    Type Description
    Double

    IsProper()

    Returns true if this distribution is proper

    Declaration
    public bool IsProper()
    Returns
    Type Description
    Boolean

    IsUniform()

    Asks whether this instance is uniform. If the upper and lower bounds are finite the distribution is not uniform.

    Declaration
    public bool IsUniform()
    Returns
    Type Description
    Boolean

    True if uniform, false otherwise

    MaxDiff(Object)

    The maximum difference between the parameters of this distribution and that

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

    PointMass(Double)

    Create a point mass distribution.

    Declaration
    [Construction(new string[]{"Point"}, UseWhen = "IsPointMass")]
    public static TruncatedGamma PointMass(double point)
    Parameters
    Type Name Description
    Double point

    The location of the point mass

    Returns
    Type Description
    TruncatedGamma

    A new TruncatedGamma with all probability concentrated on the given point.

    Sample()

    Sample from the distribution

    Declaration
    public double Sample()
    Returns
    Type Description
    Double

    The sample value

    Sample(Gamma, Double, Double)

    Sample from a TruncatedGamma distribution with the specified parameters

    Declaration
    public static double Sample(Gamma gamma, double lowerBound, double upperBound)
    Parameters
    Type Name Description
    Gamma gamma
    Double lowerBound
    Double upperBound
    Returns
    Type Description
    Double

    The sample value

    Sample(Double)

    Sample from the distribution

    Declaration
    public double Sample(double result)
    Parameters
    Type Name Description
    Double result

    Ignored

    Returns
    Type Description
    Double

    The sample value

    SetTo(TruncatedGamma)

    Set this distribution equal to value.

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

    SetToPower(TruncatedGamma, Double)

    Set this equal to (dist)^exponent

    Declaration
    public void SetToPower(TruncatedGamma dist, double exponent)
    Parameters
    Type Name Description
    TruncatedGamma dist
    Double exponent

    SetToProduct(TruncatedGamma, TruncatedGamma)

    Set this distribution equal to the product of a and b

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

    SetToRatio(TruncatedGamma, TruncatedGamma, Boolean)

    Set this equal to numerator/denominator

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

    SetToSum(Double, TruncatedGamma, Double, TruncatedGamma)

    Set the parameters to match the moments of a mixture distribution.

    Declaration
    public void SetToSum(double weight1, TruncatedGamma dist1, double weight2, TruncatedGamma dist2)
    Parameters
    Type Name Description
    Double weight1

    The first weight

    TruncatedGamma dist1

    The first distribution

    Double weight2

    The second weight

    TruncatedGamma dist2

    The second distribution

    SetToUniform()

    Set the distribution to uniform with infinite bounds

    Declaration
    public void SetToUniform()

    ToGamma()

    Get the Gamma with the same moments as this truncated Gamma.

    Declaration
    public Gamma ToGamma()
    Returns
    Type Description
    Gamma

    ToString()

    A human-readable string containing the parameters of the distribution

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    String representation of the instance

    Overrides
    ValueType.ToString()

    Uniform()

    Construct a uniform truncated Gamma. This is mathematically equivalent to a uniform Gamma.

    Declaration
    [Construction(UseWhen = "IsUniform")]
    public static TruncatedGamma Uniform()
    Returns
    Type Description
    TruncatedGamma

    Operators

    Division(TruncatedGamma, TruncatedGamma)

    Operator overload for division

    Declaration
    public static TruncatedGamma operator /(TruncatedGamma numerator, TruncatedGamma denominator)
    Parameters
    Type Name Description
    TruncatedGamma numerator
    TruncatedGamma denominator
    Returns
    Type Description
    TruncatedGamma

    Equality(TruncatedGamma, TruncatedGamma)

    Equals operator

    Declaration
    public static bool operator ==(TruncatedGamma a, TruncatedGamma b)
    Parameters
    Type Name Description
    TruncatedGamma a
    TruncatedGamma b
    Returns
    Type Description
    Boolean

    ExclusiveOr(TruncatedGamma, Double)

    Operator overload for exponentation

    Declaration
    public static TruncatedGamma operator ^(TruncatedGamma dist, double exponent)
    Parameters
    Type Name Description
    TruncatedGamma dist
    Double exponent
    Returns
    Type Description
    TruncatedGamma

    Inequality(TruncatedGamma, TruncatedGamma)

    Not equals operator

    Declaration
    public static bool operator !=(TruncatedGamma a, TruncatedGamma b)
    Parameters
    Type Name Description
    TruncatedGamma a
    TruncatedGamma b
    Returns
    Type Description
    Boolean

    Multiply(TruncatedGamma, TruncatedGamma)

    Operator overload for product.

    Declaration
    public static TruncatedGamma operator *(TruncatedGamma a, TruncatedGamma b)
    Parameters
    Type Name Description
    TruncatedGamma a
    TruncatedGamma b
    Returns
    Type Description
    TruncatedGamma

    Implements

    IDistribution<T>
    IDistribution
    System.ICloneable
    HasPoint<T>
    CanGetLogProb<T>
    SettableTo<T>
    Diffable
    SettableToProduct<T>
    SettableToProduct<T, U>
    SettableToUniform
    SettableToRatio<T>
    SettableToRatio<T, U>
    SettableToPower<T>
    Sampleable<T>
    SettableToWeightedSum<T>
    CanGetMean<MeanType>
    CanGetVariance<VarType>
    CanGetMeanAndVarianceOut<MeanType, VarType>
    CanGetLogNormalizer
    CanGetLogAverageOf<T>
    CanGetLogAverageOfPower<T>
    CanGetAverageLog<T>
    CanGetMode<ModeType>
    CanGetProbLessThan<T>
    CanGetQuantile<T>
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.