umontreal.iro.lecuyer.probdist
Class PoissonDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
-
- umontreal.iro.lecuyer.probdist.PoissonDist
-
- All Implemented Interfaces:
- Distribution
public class PoissonDist extends DiscreteDistributionInt
Extends the classDiscreteDistributionIntfor the Poisson distribution with mean λ >= 0. The mass function isp(x) = e-λλx/(x!), for x = 0, 1,...and the distribution function isF(x) = e-λ∑j=0x λj/(j!), for x = 0, 1,....If one has to compute p(x) and/or F(x) for several values of x with the same λ, where λ is not too large, then it is more efficient to instantiate an object and use the non-static methods, since the functions will then be computed once and kept in arrays.For the static methods that compute F(x) and bar(F)(x), we exploit the relationship F(x) = 1 - Gx+1(λ), where Gx+1 is the gamma distribution function with parameters (α, λ) = (x + 1, 1).
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleMAXLAMBDA-
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
-
-
Constructor Summary
Constructors Constructor and Description PoissonDist(double lambda)Creates an object that contains the probability and distribution functions, for the Poisson distribution with parameter lambda, which are computed and stored in dynamic arrays inside that object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static doublebarF(double lambda, int x)Computes and returns the value of the complementary Poisson distribution function, for λ = lambda.doublebarF(int x)Returns bar(F)(x), the complementary distribution function.static doublecdf(double lambda, int x)Computes and returns the value of the Poisson distribution function F(x) for λ = lambda.doublecdf(int x)Returns the distribution function F evaluated at x (see).static PoissonDistgetInstanceFromMLE(int[] x, int n)Creates a new instance of a Poisson distribution with parameter λ estimated using the maximum likelihood method based on the n observations x[i], i = 0, 1,…, n - 1.doublegetLambda()Returns the λ associated with this object.doublegetMean()Returns the mean of the distribution function.static doublegetMean(double lambda)Computes and returns the mean E[X] = λ of the Poisson distribution with parameter λ.static double[]getMLE(int[] x, int n)Estimates the parameter λ of the Poisson distribution using the maximum likelihood method, from the n observations x[i], i = 0, 1,…, n - 1.double[]getParams()Return a table containing the parameter of the current distribution.doublegetStandardDeviation()Returns the standard deviation of the distribution function.static doublegetStandardDeviation(double lambda)Computes and returns the standard deviation of the Poisson distribution with parameter λ.doublegetVariance()Returns the variance of the distribution function.static doublegetVariance(double lambda)Computes and returns the variance = λ of the Poisson distribution with parameter λ.static intinverseF(double lambda, double u)Performs a linear search to get the inverse function without precomputed tables.intinverseFInt(double u)Returns the inverse distribution function F-1(u), where 0 <= u <= 1.static doubleprob(double lambda, int x)Computes and returns the Poisson probability p(x) for λ = lambda..doubleprob(int x)Returns p(x), the probability of x, which should be a real number in the interval [0, 1].voidsetLambda(double lambda)Sets the λ associated with this object.java.lang.StringtoString()
-
-
-
Constructor Detail
-
PoissonDist
public PoissonDist(double lambda)
Creates an object that contains the probability and distribution functions, for the Poisson distribution with parameter lambda, which are computed and stored in dynamic arrays inside that object.
-
-
Method Detail
-
prob
public double prob(int x)
Description copied from class:DiscreteDistributionIntReturns p(x), the probability of x, which should be a real number in the interval [0, 1].- Specified by:
probin classDiscreteDistributionInt- Parameters:
x- value at which the mass function must be evaluated- Returns:
- the mass function evaluated at x
-
cdf
public double cdf(int x)
Description copied from class:DiscreteDistributionIntReturns the distribution function F evaluated at x (see).- Specified by:
cdfin classDiscreteDistributionInt- Parameters:
x- value at which the distribution function must be evaluated- Returns:
- the distribution function evaluated at x
-
barF
public double barF(int x)
Description copied from class:DiscreteDistributionIntReturns bar(F)(x), the complementary distribution function. See the WARNING above.- Overrides:
barFin classDiscreteDistributionInt- Parameters:
x- value at which the complementary distribution function must be evaluated- Returns:
- the complementary distribution function evaluated at x
-
inverseFInt
public int inverseFInt(double u)
Description copied from class:DiscreteDistributionIntReturns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.- Overrides:
inverseFIntin classDiscreteDistributionInt- Parameters:
u- value in the interval (0, 1) for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getMean
public double getMean()
Description copied from interface:DistributionReturns the mean of the distribution function.
-
getVariance
public double getVariance()
Description copied from interface:DistributionReturns the variance of the distribution function.
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:DistributionReturns the standard deviation of the distribution function.
-
prob
public static double prob(double lambda, int x)Computes and returns the Poisson probability p(x) for λ = lambda..
-
cdf
public static double cdf(double lambda, int x)Computes and returns the value of the Poisson distribution function F(x) for λ = lambda.
-
barF
public static double barF(double lambda, int x)Computes and returns the value of the complementary Poisson distribution function, for λ = lambda. WARNING: The complementary distribution function is defined as bar(F)(x) = P[X >= x].
-
inverseF
public static int inverseF(double lambda, double u)Performs a linear search to get the inverse function without precomputed tables.
-
getMLE
public static double[] getMLE(int[] x, int n)Estimates the parameter λ of the Poisson distribution using the maximum likelihood method, from the n observations x[i], i = 0, 1,…, n - 1. The maximum likelihood estimator hat(λ) satisfy the equation hat(λ) = bar(x)n, where bar(x)n is the average of x[0],…, x[n - 1] (see).- Parameters:
x- the list of observations used to evaluate parametersn- the number of observations used to evaluate parameters- Returns:
- returns the parameter [ hat(λ)]
-
getInstanceFromMLE
public static PoissonDist getInstanceFromMLE(int[] x, int n)
Creates a new instance of a Poisson distribution with parameter λ estimated using the maximum likelihood method based on the n observations x[i], i = 0, 1,…, n - 1.- Parameters:
x- the list of observations to use to evaluate parametersn- the number of observations to use to evaluate parameters
-
getMean
public static double getMean(double lambda)
Computes and returns the mean E[X] = λ of the Poisson distribution with parameter λ.- Returns:
- the mean of the Poisson distribution E[X] = λ
-
getVariance
public static double getVariance(double lambda)
Computes and returns the variance = λ of the Poisson distribution with parameter λ.- Returns:
- the variance of the Poisson distribution Var[X] = λ
-
getStandardDeviation
public static double getStandardDeviation(double lambda)
Computes and returns the standard deviation of the Poisson distribution with parameter λ.- Returns:
- the standard deviation of the Poisson distribution
-
getLambda
public double getLambda()
Returns the λ associated with this object.
-
setLambda
public void setLambda(double lambda)
Sets the λ associated with this object.
-
getParams
public double[] getParams()
Return a table containing the parameter of the current distribution.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG