Class LeftTruncatedPoisson
Left-truncated Com-Poisson distribution.
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Distributions
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[DataContract]
[Quality(QualityBand.Experimental)]
public class LeftTruncatedPoisson : IDistribution<int>, IDistribution, ICloneable, Diffable, SettableToUniform, HasPoint<int>, CanGetLogProb<int>, CanGetMean<double>, Sampleable<int>, SettableToProduct<LeftTruncatedPoisson>, SettableToProduct<LeftTruncatedPoisson, LeftTruncatedPoisson>, SettableToRatio<LeftTruncatedPoisson>, SettableToRatio<LeftTruncatedPoisson, LeftTruncatedPoisson>, SettableToPower<LeftTruncatedPoisson>, SettableToWeightedSum<LeftTruncatedPoisson>, SettableTo<LeftTruncatedPoisson>, SettableTo<Discrete>, SettableToPartialUniform<LeftTruncatedPoisson>, SettableToPartialUniform<Discrete>, CanGetLogAverageOf<LeftTruncatedPoisson>, CanGetAverageLog<LeftTruncatedPoisson>, CanGetLogNormalizer, ICanTruncateLeft<int>
Constructors
LeftTruncatedPoisson()
Initializes a new instance of the LeftTruncatedPoisson class.
Declaration
public LeftTruncatedPoisson()
LeftTruncatedPoisson(Poisson, Int32)
Initializes a new instance of the LeftTruncatedPoisson class.
Declaration
public LeftTruncatedPoisson(Poisson nonTruncatedDistribution, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Poisson | nonTruncatedDistribution | The non-truncated CoM-Poisson distribution. |
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
LeftTruncatedPoisson(Double, Double, Int32)
Initializes a new instance of the LeftTruncatedPoisson class.
Declaration
[Construction(new string[]{"Rate", "Precision", "StartPoint"})]
public LeftTruncatedPoisson(double rate, double precision, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Double | rate | The rate parameter of the underlying CoM-Poisson distribution. |
Double | precision | The precision parameter of the underlying CoM-Poisson distribution. |
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
LeftTruncatedPoisson(Double, Int32)
Initializes a new instance of the LeftTruncatedPoisson class.
Declaration
public LeftTruncatedPoisson(double rate, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Double | rate | The rate parameter of the underlying Poisson distribution. The precision parameter is assumed to be 1.0. |
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
Fields
Tolerance
Tolerance for numerical calculations.
Declaration
public const double Tolerance = 1E-10
Field Value
Type | Description |
---|---|
Double |
Properties
IsPointMass
Gets a value indicating whether the current distribution represents a point mass.
Declaration
public bool IsPointMass { get; }
Property Value
Type | Description |
---|---|
Boolean |
LogNormalizer
Returns the log normalizer of the instance.
Declaration
public double LogNormalizer { get; }
Property Value
Type | Description |
---|---|
Double |
MeanLogFactorial
Returns the mean log factorial of the instance.
Declaration
public double MeanLogFactorial { get; }
Property Value
Type | Description |
---|---|
Double |
Point
Gets or sets the distribution as a point mass.
Declaration
public int Point { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Precision
Gets or sets the precision parameter of the COM-Poisson distribution
Declaration
public double Precision { get; set; }
Property Value
Type | Description |
---|---|
Double |
Rate
Gets or sets the rate parameter of the COM-Poisson distribution, always >= 0.
Declaration
public double Rate { get; set; }
Property Value
Type | Description |
---|---|
Double |
StartPoint
The first non-zero point.
Declaration
[DataMember]
public int StartPoint { get; }
Property Value
Type | Description |
---|---|
Int32 |
SumLogFactorial
Returns the log normalizer of the instance.
Declaration
public double SumLogFactorial { get; }
Property Value
Type | Description |
---|---|
Double |
Methods
Clone()
Creates a cloned copy of this distribution.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
Object | The copy. |
FromMeanAndStartPoint(Double, Double, Int32, Double, Int32)
Initializes a new instance of the LeftTruncatedPoisson struct given a target mean and a start point.
Declaration
public static LeftTruncatedPoisson FromMeanAndStartPoint(double targetMean, double precision, int startPoint, double tolerance = 1E-10, int maxIterations = 100)
Parameters
Type | Name | Description |
---|---|---|
Double | targetMean | The desired mean of the Truncated Poisson. |
Double | precision | The desired precision of the Truncated Poisson. |
Int32 | startPoint | The start point. |
Double | tolerance | Tolerance for mean. |
Int32 | maxIterations | Maximum iterations for binary search. |
Returns
Type | Description |
---|---|
LeftTruncatedPoisson | A new instance with the target mean. |
GetAverageLog(LeftTruncatedPoisson)
Gets the expected logarithm of a truncated COM-Poisson under this truncated COM-Poisson.
Declaration
public double GetAverageLog(LeftTruncatedPoisson that)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | that | The distribution to take the logarithm of. |
Returns
Type | Description |
---|---|
Double |
|
Remarks
This is also known as the cross entropy.
GetLogAverageOf(LeftTruncatedPoisson)
Gets the log of the integral of the product of this truncated COM-Poisson with another truncated COM-Poisson.
Declaration
public double GetLogAverageOf(LeftTruncatedPoisson that)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | that | The other truncated COM-Poisson |
Returns
Type | Description |
---|---|
Double |
GetLogNormalizer()
Gets the log of the normalizer of this distribution.
Declaration
public double GetLogNormalizer()
Returns
Type | Description |
---|---|
Double | The log of the normalizer. |
GetLogNormalizer(Double, Double, Int32)
Gets the log normalizer of a left-truncated Poisson. TODO: integrate this with Poisson.GetLogNormalizer.
Declaration
public static double GetLogNormalizer(double rate, double prec, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Double | rate | Rate parameter. |
Double | prec | Precision parameter. |
Int32 | startPoint | Start point. |
Returns
Type | Description |
---|---|
Double | The log normalizer of the distribution. |
GetLogProb(Int32)
Gets the log probability for a given domain value.
Declaration
public double GetLogProb(int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The domain value. |
Returns
Type | Description |
---|---|
Double | The log probability of the value. |
GetLogProb(Int32, Double, Double, Double)
Gets the log probability when some calculations have been done externally.
Declaration
public static double GetLogProb(int value, double logRate, double precision, double logNormalizer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The domain value. |
Double | logRate | The log of the rate. |
Double | precision | The precision. |
Double | logNormalizer | The log normalizer. |
Returns
Type | Description |
---|---|
Double | The log probability of the value. |
GetMean()
Gets the mean of this distribution.
Declaration
public double GetMean()
Returns
Type | Description |
---|---|
Double | The mean. |
GetStartPoint()
Gets the start point of the truncated distribution.
Declaration
public int GetStartPoint()
Returns
Type | Description |
---|---|
Int32 | The start point. |
GetSumLogFactorial(Double, Double, Int32)
Computes sum_{x=start..infinity} log(x!) lambda^x / x!^nu
Declaration
public static double GetSumLogFactorial(double lambda, double nu, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Double | lambda | The rate. |
Double | nu | The precision. |
Int32 | startPoint | The start point. |
Returns
Type | Description |
---|---|
Double | The sum log factorial. |
IsPartialUniform()
Checks whether the distribution is uniform over its support.
Declaration
public bool IsPartialUniform()
Returns
Type | Description |
---|---|
Boolean | True if the distribution is uniform over its support, false otherwise. |
IsProper()
Asks whether this instance is proper or not. A truncated COM-Poisson distribution is proper if Rate >= 0 and (Precision > 0 or (Precision == 0 and Rate < 1)).
Declaration
public bool IsProper()
Returns
Type | Description |
---|---|
Boolean | True if proper, false otherwise |
IsUniform()
Gets a value indicating whether the current distribution is uniform.
Declaration
public bool IsUniform()
Returns
Type | Description |
---|---|
Boolean |
MaxDiff(Object)
Gets a value indicating how close this distribution is to another distribution. in terms of probabilities they assign to sequences.
Declaration
public double MaxDiff(object that)
Parameters
Type | Name | Description |
---|---|---|
Object | that | The other distribution. |
Returns
Type | Description |
---|---|
Double | The max difference. |
PointMass(Int32)
Creates a truncated Com-Poisson distribution which only allows one value.
Declaration
[Construction(new string[]{"Point"}, UseWhen = "IsPointMass")]
public static LeftTruncatedPoisson PointMass(int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The value of the point mass. |
Returns
Type | Description |
---|---|
LeftTruncatedPoisson | A point mass at the given value. |
Sample()
Emits a random sample from this distribution.
Declaration
public int Sample()
Returns
Type | Description |
---|---|
Int32 | A random sample. |
Sample(Int32)
Emits a random sample from this distribution.
Declaration
public int Sample(int result)
Parameters
Type | Name | Description |
---|---|---|
Int32 | result | This argument is ignored. |
Returns
Type | Description |
---|---|
Int32 | A random sample. |
SetTo(Discrete)
Set the instance to have the same value as given
Declaration
public void SetTo(Discrete value)
Parameters
Type | Name | Description |
---|---|---|
Discrete | value |
SetTo(LeftTruncatedPoisson)
Set the instance to have the same value as given
Declaration
public void SetTo(LeftTruncatedPoisson value)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | value |
SetToPartialUniform()
Set non-zero support to uniform
Declaration
public void SetToPartialUniform()
SetToPartialUniform(Int32)
Sets the current distribution to be uniform beyond a given start point.
Declaration
public void SetToPartialUniform(int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint | The start point. |
SetToPartialUniformOf(Discrete)
Sets the distribution to be uniform over the support of a given distribution.
Declaration
public void SetToPartialUniformOf(Discrete dist)
Parameters
Type | Name | Description |
---|---|---|
Discrete | dist |
SetToPartialUniformOf(LeftTruncatedPoisson)
Sets the distribution to be uniform over the support of a given distribution.
Declaration
public void SetToPartialUniformOf(LeftTruncatedPoisson dist)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | dist |
SetToPower(LeftTruncatedPoisson, Double)
Sets the parameters to represent the power of a truncated COM-Poisson to some exponent.
Declaration
public void SetToPower(LeftTruncatedPoisson dist, double exponent)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | dist | The source truncated COM-Poisson |
Double | exponent | The exponent |
SetToProduct(LeftTruncatedPoisson, LeftTruncatedPoisson)
Sets the parameters to represent the product of two truncated COM-Poissons.
Declaration
public void SetToProduct(LeftTruncatedPoisson a, LeftTruncatedPoisson b)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | a | The first truncated COM-Poisson |
LeftTruncatedPoisson | b | The second truncated COM-Poisson |
SetToRatio(LeftTruncatedPoisson, LeftTruncatedPoisson, Boolean)
Sets the parameters to represent the ratio of two truncated COM-Poisson distributions
Declaration
public void SetToRatio(LeftTruncatedPoisson numerator, LeftTruncatedPoisson denominator, bool forceProper = false)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | numerator | The numerator truncated distribution |
LeftTruncatedPoisson | denominator | The denominator truncated distribution |
Boolean | forceProper | If true, the result has precision >= 0 and rate <= 1 |
Remarks
The result may not be proper. No error is thrown in this case.
SetToSum(Double, LeftTruncatedPoisson, Double, LeftTruncatedPoisson)
Set the parameters to match the moments of a mixture distribution.
Declaration
public void SetToSum(double weight1, LeftTruncatedPoisson dist1, double weight2, LeftTruncatedPoisson dist2)
Parameters
Type | Name | Description |
---|---|---|
Double | weight1 | The first weight |
LeftTruncatedPoisson | dist1 | The first distribution |
Double | weight2 | The second weight |
LeftTruncatedPoisson | dist2 | The second distribution |
SetToUniform()
Sets the current distribution to be uniform.
Declaration
public void SetToUniform()
ToString()
Overrides ToString method.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | String representation of instance. |
Overrides
TruncatedUniform(Int32)
Instantiates a uniform truncated Com-Poisson distribution beyond a given start point.
Declaration
public static LeftTruncatedPoisson TruncatedUniform(int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint | Start point. |
Returns
Type | Description |
---|---|
LeftTruncatedPoisson | A new uniform Com-Poisson distribution |
TruncateLeft(Int32)
Truncates the distribution at the given point.
Declaration
public void TruncateLeft(int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint |
Uniform()
Instantiates a uniform truncated Com-Poisson distribution
Declaration
[Construction(UseWhen = "IsUniform")]
public static LeftTruncatedPoisson Uniform()
Returns
Type | Description |
---|---|
LeftTruncatedPoisson | A new uniform Com-Poisson distribution |
Operators
Division(LeftTruncatedPoisson, LeftTruncatedPoisson)
Creates a new truncated COM-Poisson which is the ratio of two other truncated COM-Poissons
Declaration
public static LeftTruncatedPoisson operator /(LeftTruncatedPoisson numerator, LeftTruncatedPoisson denominator)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | numerator | The numerator distribution |
LeftTruncatedPoisson | denominator | The denominator distribution |
Returns
Type | Description |
---|---|
LeftTruncatedPoisson | Result of the ratio calculation. |
ExclusiveOr(LeftTruncatedPoisson, Double)
Raises a truncated COM-Poisson to a power.
Declaration
public static LeftTruncatedPoisson operator ^(LeftTruncatedPoisson dist, double exponent)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | dist | The distribution. |
Double | exponent | The power to raise to. |
Returns
Type | Description |
---|---|
LeftTruncatedPoisson |
|
Multiply(LeftTruncatedPoisson, LeftTruncatedPoisson)
Creates a new truncated COM-Poisson which is the product of two other truncated COM-Poissons
Declaration
public static LeftTruncatedPoisson operator *(LeftTruncatedPoisson a, LeftTruncatedPoisson b)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | a | The first COM-Poisson |
LeftTruncatedPoisson | b | The second COM-Poisson |
Returns
Type | Description |
---|---|
LeftTruncatedPoisson | Result of the product. |