Click or drag to resize
Accord.NET (logo)

PoissonDistribution Class

Poisson probability distribution.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.UnivariateUnivariateDiscreteDistribution
      Accord.Statistics.Distributions.UnivariatePoissonDistribution

Namespace:  Accord.Statistics.Distributions.Univariate
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.5.0
Syntax
[SerializableAttribute]
public class PoissonDistribution : UnivariateDiscreteDistribution, 
	IFittableDistribution<double, IFittingOptions>, IFittable<double, IFittingOptions>, 
	IFittable<double>, IFittableDistribution<double>, IDistribution<double>, 
	IDistribution, ICloneable, ISampleableDistribution<int>, IDistribution<int>, 
	IRandomNumberGenerator<int>
Request Example View Source

The PoissonDistribution type exposes the following members.

Constructors
  NameDescription
Public methodPoissonDistribution
Creates a new Poisson distribution with λ = 1.
Public methodPoissonDistribution(Double)
Creates a new Poisson distribution with the given λ (lambda).
Top
Properties
  NameDescription
Public propertyEntropy
Gets the entropy for this distribution.
(Overrides UnivariateDiscreteDistributionEntropy.)
Public propertyLambda
Gets the Poisson's parameter λ (lambda).
Public propertyMean
Gets the mean for this distribution.
(Overrides UnivariateDiscreteDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertyMode
Gets the mode for this distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertyQuartiles
Gets the Quartiles for this distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertyStatic memberStandard
Gets the standard Poisson distribution, with lambda (rate) equal to 1.
Public propertyStandardDeviation
Gets the Standard Deviation (the square root of the variance) for the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public propertySupport
Gets the support interval for this distribution.
(Overrides UnivariateDiscreteDistributionSupport.)
Public propertyVariance
Gets the variance for this distribution.
(Overrides UnivariateDiscreteDistributionVariance.)
Top
Methods
  NameDescription
Protected methodBaseInverseDistributionFunction
Gets the inverse of the cumulative distribution function (icdf) for this distribution evaluated at probability p using a numerical approximation based on binary search.
(Inherited from UnivariateDiscreteDistribution.)
Public methodClone
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)
Public methodComplementaryDistributionFunction(Int32)
Gets P(X > k) the complementary cumulative distribution function (ccdf) for this distribution evaluated at point k. This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.)
Public methodCode exampleComplementaryDistributionFunction(Int32, Boolean)
Gets the complementary cumulative distribution function (ccdf) for this distribution evaluated at point k. This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.)
Public methodCumulativeHazardFunction
Gets the cumulative hazard function for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Public methodDistributionFunction(Int32)
Gets the cumulative distribution function (cdf) for this distribution evaluated at point k.
(Overrides UnivariateDiscreteDistributionDistributionFunction(Int32).)
Public methodCode exampleDistributionFunction(Int32, Boolean)
Gets P(X ≤ k) or P(X < k), the cumulative distribution function (cdf) for this distribution evaluated at point k, depending on the value of the inclusive parameter.
(Inherited from UnivariateDiscreteDistribution.)
Public methodDistributionFunction(Int32, Int32)
Gets the cumulative distribution function (cdf) for this distribution in the semi-closed interval (a; b] given as P(a < X ≤ b).
(Inherited from UnivariateDiscreteDistribution.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Double, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateDiscreteDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Double, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32, Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodFit(Int32, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate
Generates a random observation from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate.)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate(Int32, Double).)
Public methodGenerate(Int32, Int32)
Generates a random vector of observations from the current distribution.
(Overrides UnivariateDiscreteDistributionGenerate(Int32, Int32).)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetRange
Gets the distribution range within a given percentile.
(Inherited from UnivariateDiscreteDistribution.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodHazardFunction
Gets the hazard function, also known as the failure rate or the conditional failure density function for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Public methodInverseDistributionFunction
Gets the inverse of the cumulative distribution function (icdf) for this distribution evaluated at probability p. This function is also known as the Quantile function.
(Inherited from UnivariateDiscreteDistribution.)
Public methodLogCumulativeHazardFunction
Gets the log-cumulative hazard function for this distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)
Public methodLogProbabilityMassFunction
Gets the log-probability mass function (pmf) for this distribution evaluated at point k.
(Overrides UnivariateDiscreteDistributionLogProbabilityMassFunction(Int32).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProbabilityMassFunction
Gets the probability mass function (pmf) for this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionProbabilityMassFunction(Int32).)
Public methodQuantileDensityFunction
Gets the first derivative of the inverse distribution function (icdf) for this distribution evaluated at probability p.
(Inherited from UnivariateDiscreteDistribution.)
Public methodToString
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(IFormatProvider)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String, IFormatProvider)
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by Matrix.)
Top
Remarks

The Poisson distribution is a discrete probability distribution that expresses the probability of a number of events occurring in a fixed period of time if these events occur with a known average rate and independently of the time since the last event.

References:

Examples

The following example shows how to instantiate a new Poisson distribution with a given rate λ and how to compute its measures and associated functions.

// Create a new Poisson distribution with 
var dist = new PoissonDistribution(lambda: 4.2);

// Common measures
double mean = dist.Mean;     // 4.2
double median = dist.Median; // 4.0
double var = dist.Variance;  // 4.2

// Cumulative distribution functions
double cdf1 = dist.DistributionFunction(k: 2); // 0.21023798702309743
double cdf2 = dist.DistributionFunction(k: 4); // 0.58982702131057763
double cdf3 = dist.DistributionFunction(k: 7); // 0.93605666027257894
double ccdf = dist.ComplementaryDistributionFunction(k: 2); // 0.78976201297690252

// Probability mass functions
double pmf1 = dist.ProbabilityMassFunction(k: 4); // 0.19442365170822165
double pmf2 = dist.ProbabilityMassFunction(k: 5); // 0.1633158674349062
double pmf3 = dist.ProbabilityMassFunction(k: 6); // 0.11432110720443435
double lpmf = dist.LogProbabilityMassFunction(k: 2); // -2.0229781299813

// Quantile function
int icdf1 = dist.InverseDistributionFunction(p: cdf1); // 2
int icdf2 = dist.InverseDistributionFunction(p: cdf2); // 4
int icdf3 = dist.InverseDistributionFunction(p: cdf3); // 7

// Hazard (failure rate) functions
double hf = dist.HazardFunction(x: 4); // 0.47400404660843515
double chf = dist.CumulativeHazardFunction(x: 4); // 0.89117630901575073

// String representation
string str = dist.ToString(CultureInfo.InvariantCulture); // "Poisson(x; λ = 4.2)"

This example shows hows to call the distribution function to compute different types of probabilities.

// Create a new Poisson distribution
var dist = new PoissonDistribution(lambda: 4.2);

// P(X = 1) = 0.0629814226460064
double equal = dist.ProbabilityMassFunction(k: 1);

// P(X < 1) = 0.0149955768204777
double less = dist.DistributionFunction(k: 1, inclusive: false);

// P(X ≤ 1) = 0.0779769994664841
double lessThanOrEqual = dist.DistributionFunction(k: 1, inclusive: true);

// P(X > 1) = 0.922023000533516
double greater = dist.ComplementaryDistributionFunction(k: 1);

// P(X ≥ 1) = 0.985004423179522
double greaterThanOrEqual = dist.ComplementaryDistributionFunction(k: 1, inclusive: true);
See Also