Class TruncatedPoisson
Left-and-right-truncated Com-Poisson distribution.
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Distributions
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[DataContract]
[Quality(QualityBand.Experimental)]
public class TruncatedPoisson : IDistribution<int>, IDistribution, ICloneable, Diffable, SettableToUniform, HasPoint<int>, CanGetLogProb<int>, CanGetMean<double>, Sampleable<int>, SettableToProduct<TruncatedPoisson>, SettableToProduct<TruncatedPoisson, TruncatedPoisson>, SettableTo<TruncatedPoisson>, SettableTo<LeftTruncatedPoisson>, SettableTo<Discrete>, SettableToPartialUniform<TruncatedPoisson>, SettableToPartialUniform<Discrete>, CanGetLogAverageOf<TruncatedPoisson>, CanGetAverageLog<TruncatedPoisson>, CanGetLogNormalizer, ICanTruncateLeft<int>, ICanTruncateRight<int>
Constructors
TruncatedPoisson()
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson()
TruncatedPoisson(LeftTruncatedPoisson)
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson(LeftTruncatedPoisson truncatedDistribution)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | truncatedDistribution | The underlying left-truncated CoM-Poisson distribution. |
TruncatedPoisson(LeftTruncatedPoisson, Int32)
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson(LeftTruncatedPoisson leftTruncatedDistribution, int endPoint)
Parameters
Type | Name | Description |
---|---|---|
LeftTruncatedPoisson | leftTruncatedDistribution | The underlying left-truncated CoM-Poisson distribution. |
Int32 | endPoint | The index of the last non-zero term in the truncated distribution. |
TruncatedPoisson(Poisson, Int32)
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson(Poisson nonTruncatedDistribution, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Poisson | nonTruncatedDistribution | The underlying CoM-Poisson distribution. |
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
TruncatedPoisson(Poisson, Int32, Int32)
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson(Poisson nonTruncatedDistribution, int startPoint, int endPoint)
Parameters
Type | Name | Description |
---|---|---|
Poisson | nonTruncatedDistribution | The underlying CoM-Poisson distribution. |
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
Int32 | endPoint | The index of the last non-zero term in the truncated distribution. |
TruncatedPoisson(Double, Double, Int32)
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson(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. |
TruncatedPoisson(Double, Double, Int32, Int32)
Initializes a new instance of the TruncatedPoisson class.
Declaration
[Construction(new string[]{"Rate", "Precision", "StartPoint", "EndPoint"})]
public TruncatedPoisson(double rate, double precision, int startPoint, int endPoint)
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. |
Int32 | endPoint | The index of the last non-zero term in the truncated distribution. |
TruncatedPoisson(Double, Int32)
Initializes a new instance of the TruncatedPoisson class.
Declaration
public TruncatedPoisson(double rate, int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Double | rate | The rate parameter of the underlying CoM-Poisson distribution. |
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
Fields
PositiveInfinityEndPoint
Declaration
public const int PositiveInfinityEndPoint = 2147483647
Field Value
Type | Description |
---|---|
Int32 |
Properties
EndPoint
The last non-zero point.
Declaration
[DataMember]
public int EndPoint { get; }
Property Value
Type | Description |
---|---|
Int32 |
EndPointIsPositiveInfinity
Gets a value indicating whether the current distribution is right-truncated.
Declaration
public bool EndPointIsPositiveInfinity { get; }
Property Value
Type | Description |
---|---|
Boolean |
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 |
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
public int StartPoint { get; }
Property Value
Type | Description |
---|---|
Int32 |
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 TruncatedPoisson struct given a target mean, a start point and a end point.
Declaration
public static TruncatedPoisson 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 |
---|---|
TruncatedPoisson | A new instance with the target mean. |
FromMeanAndStartPointAndEndPoint(Double, Double, Int32, Int32, Double, Int32)
Initializes a new instance of the TruncatedPoisson struct given a target mean, a start point and a end point.
Declaration
public static TruncatedPoisson FromMeanAndStartPointAndEndPoint(double targetMean, double precision, int startPoint, int endPoint, 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. |
Int32 | endPoint | The end point. |
Double | tolerance | Tolerance for mean. |
Int32 | maxIterations | Maximum iterations for binary search. |
Returns
Type | Description |
---|---|
TruncatedPoisson | A new instance with the target mean. |
GetAverageLog(TruncatedPoisson)
The expected logarithm of that distribution under this distribution.
Declaration
public double GetAverageLog(TruncatedPoisson that)
Parameters
Type | Name | Description |
---|---|---|
TruncatedPoisson | that |
Returns
Type | Description |
---|---|
Double |
|
Remarks
This is also known as the cross entropy.
GetEndPoint()
Gets the end point of the truncated distribution.
Declaration
public int GetEndPoint()
Returns
Type | Description |
---|---|
Int32 | The end point. |
GetLogAverageOf(TruncatedPoisson)
Gets the log of the integral of the product of this truncated COM-Poisson with another truncated COM-Poisson.
Declaration
public double GetLogAverageOf(TruncatedPoisson that)
Parameters
Type | Name | Description |
---|---|---|
TruncatedPoisson | 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, Int32)
Gets the log normalizer of a truncated Poisson.
Declaration
public static double GetLogNormalizer(double rate, double prec, int startPoint, int endPoint)
Parameters
Type | Name | Description |
---|---|---|
Double | rate | Rate parameter. |
Double | prec | Precision parameter. |
Int32 | startPoint | Start point. |
Int32 | endPoint | End 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. |
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. |
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. |
PartialUniform(Int32)
Instantiates a uniform truncated Com-Poisson distribution beyond a given start point.
Declaration
public static TruncatedPoisson PartialUniform(int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
Returns
Type | Description |
---|---|
TruncatedPoisson | A new uniform truncated Com-Poisson distribution |
PartialUniform(Int32, Int32)
Instantiates a uniform truncated Com-Poisson distribution between given start and end points.
Declaration
public static TruncatedPoisson PartialUniform(int startPoint, int endPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
Int32 | endPoint | The index of the last non-zero term in the truncated distribution. |
Returns
Type | Description |
---|---|
TruncatedPoisson | A new uniform truncated Com-Poisson distribution |
PointMass(Int32)
Creates a truncated Com-Poisson distribution which only allows one value.
Declaration
[Construction(new string[]{"Point"}, UseWhen = "IsPointMass")]
public static TruncatedPoisson PointMass(int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The value of the point mass. |
Returns
Type | Description |
---|---|
TruncatedPoisson | 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 |
SetTo(TruncatedPoisson)
Set the instance to have the same value as given
Declaration
public void SetTo(TruncatedPoisson value)
Parameters
Type | Name | Description |
---|---|---|
TruncatedPoisson | value |
SetToPartialUniform()
Sets the distribution to be uniform over its support.
Declaration
public void SetToPartialUniform()
SetToPartialUniform(Int32, Int32)
Sets the current distribution to be uniform between given start and end points.
Declaration
public void SetToPartialUniform(int startPoint, int endPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint | The index of the first non-zero term in the truncated distribution. |
Int32 | endPoint | The index of the last non-zero term in the truncated distribution. |
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(TruncatedPoisson)
Sets the distribution to be uniform over the support of a given distribution.
Declaration
public void SetToPartialUniformOf(TruncatedPoisson dist)
Parameters
Type | Name | Description |
---|---|---|
TruncatedPoisson | dist |
SetToProduct(TruncatedPoisson, TruncatedPoisson)
Sets the parameters to represent the product of two truncated COM-Poissons.
Declaration
public void SetToProduct(TruncatedPoisson a, TruncatedPoisson b)
Parameters
Type | Name | Description |
---|---|---|
TruncatedPoisson | a | The first truncated COM-Poisson |
TruncatedPoisson | b | The second truncated COM-Poisson |
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
TruncateLeft(Int32)
Truncates the distribution at the given point.
Declaration
public void TruncateLeft(int startPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | startPoint |
TruncateRight(Int32)
Truncates the distribution at the given point.
Declaration
public void TruncateRight(int endPoint)
Parameters
Type | Name | Description |
---|---|---|
Int32 | endPoint |
Uniform()
Instantiates a uniform truncated Com-Poisson distribution
Declaration
[Construction(UseWhen = "IsUniform")]
public static TruncatedPoisson Uniform()
Returns
Type | Description |
---|---|
TruncatedPoisson | A new uniform Com-Poisson distribution |