Class PoissonDistribution
- java.lang.Object
-
- elki.math.statistics.distribution.PoissonDistribution
-
- All Implemented Interfaces:
Distribution
public class PoissonDistribution extends java.lang.Object implements Distribution
INCOMPLETE implementation of the poisson distribution.TODO: continue implementing, CDF, invcdf and nextRandom are missing
References:
Catherine Loader
Fast and Accurate Computation of Binomial Probabilities.- Since:
- 0.5.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPoissonDistribution.ParParameterization class-
Nested classes/interfaces inherited from interface elki.math.statistics.distribution.Distribution
Distribution.Parameterizer
-
-
Field Summary
Fields Modifier and Type Field Description private intnNumber of triesprivate doublepSuccess probabilityprivate static doubleS0Stirling error constants: 1./12private static doubleS1Stirling error constants: 1./360private static doubleS2Stirling error constants: 1./1260private static doubleS3Stirling error constants: 1./1680private static doubleS4Stirling error constants: 1./1188private static double[]STIRLING_EXACT_ERRORExact table values for n <= 15 in steps of 0.5
-
Constructor Summary
Constructors Constructor Description PoissonDistribution(int n, double p)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(double val)Return the cumulative density function at the given value.private static doubledevianceTerm(double x, double np)Evaluate the deviance term of the saddle point approximation.doublelogpdf(double x)Return the log density of an existing valuestatic doublelogpmf(double x, int n, double p)Poisson probability mass function (PMF) for integer values.static doublelogpoissonPDFm1(double x_plus_1, double lambda)Compute the poisson distribution PDF with an offset of + 1doublenextRandom(java.util.Random random)Generate a new random valuedoublepdf(double x)Return the density of an existing valuestatic doublepmf(double x, int n, double p)Poisson probability mass function (PMF) for integer values.doublepmf(int x)Poisson probability mass function (PMF) for integer values.static doublepoissonPDFm1(double x_plus_1, double lambda)Compute the poisson distribution PDF with an offset of + 1doublequantile(double val)Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.static doublerawLogProbability(double x, double lambda)Poisson distribution probability, but also for non-integer arguments.static doublerawProbability(double x, double lambda)Poisson distribution probability, but also for non-integer arguments.private static doublestirlingError(double n)Calculates the Stirling Errorprivate static doublestirlingError(int n)Calculates the Stirling Errorjava.lang.StringtoString()Describe the distribution
-
-
-
Field Detail
-
n
private int n
Number of tries
-
p
private double p
Success probability
-
S0
private static final double S0
Stirling error constants: 1./12- See Also:
- Constant Field Values
-
S1
private static final double S1
Stirling error constants: 1./360- See Also:
- Constant Field Values
-
S2
private static final double S2
Stirling error constants: 1./1260- See Also:
- Constant Field Values
-
S3
private static final double S3
Stirling error constants: 1./1680- See Also:
- Constant Field Values
-
S4
private static final double S4
Stirling error constants: 1./1188- See Also:
- Constant Field Values
-
STIRLING_EXACT_ERROR
private static final double[] STIRLING_EXACT_ERROR
Exact table values for n <= 15 in steps of 0.5sfe[n] = ln( (n!*e^n)/((n^n)*sqrt(2*pi*n)) )
-
-
Method Detail
-
pmf
public double pmf(int x)
Poisson probability mass function (PMF) for integer values.- Parameters:
x- integer values- Returns:
- Probability
-
pdf
public double pdf(double x)
Description copied from interface:DistributionReturn the density of an existing value- Specified by:
pdfin interfaceDistribution- Parameters:
x- existing value- Returns:
- distribution density
-
logpdf
public double logpdf(double x)
Description copied from interface:DistributionReturn the log density of an existing value- Specified by:
logpdfin interfaceDistribution- Parameters:
x- existing value- Returns:
- log distribution density
-
pmf
@Reference(title="Fast and accurate computation of binomial probabilities", authors="C. Loader", booktitle="", url="http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf", bibkey="web/Loader00") public static double pmf(double x, int n, double p)
Poisson probability mass function (PMF) for integer values.- Parameters:
x- integer values- Returns:
- Probability
-
logpmf
public static double logpmf(double x, int n, double p)Poisson probability mass function (PMF) for integer values.- Parameters:
x- integer values- Returns:
- Probability
-
cdf
public double cdf(double val)
Description copied from interface:DistributionReturn the cumulative density function at the given value.- Specified by:
cdfin interfaceDistribution- Parameters:
val- existing value- Returns:
- cumulative density
-
quantile
public double quantile(double val)
Description copied from interface:DistributionQuantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.- Specified by:
quantilein interfaceDistribution- Parameters:
val- Quantile to find- Returns:
- Quantile position
-
nextRandom
public double nextRandom(java.util.Random random)
Description copied from interface:DistributionGenerate a new random value- Specified by:
nextRandomin interfaceDistribution- Parameters:
random- Random number generator- Returns:
- new random value
-
poissonPDFm1
public static double poissonPDFm1(double x_plus_1, double lambda)Compute the poisson distribution PDF with an offset of + 1pdf(x_plus_1 - 1, lambda)
- Parameters:
x_plus_1- x+1lambda- Lambda- Returns:
-
logpoissonPDFm1
public static double logpoissonPDFm1(double x_plus_1, double lambda)Compute the poisson distribution PDF with an offset of + 1log pdf(x_plus_1 - 1, lambda)
- Parameters:
x_plus_1- x+1lambda- Lambda- Returns:
-
stirlingError
@Reference(title="Fast and accurate computation of binomial probabilities", authors="C. Loader", booktitle="", url="http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf", bibkey="web/Loader00") private static double stirlingError(int n)
Calculates the Stirling Errorstirlerr(n) = ln(n!) - ln(sqrt(2*pi*n)*(n/e)^n)
- Parameters:
n- Parameter n- Returns:
- Stirling error
-
stirlingError
@Reference(title="Fast and accurate computation of binomial probabilities", authors="C. Loader", booktitle="", url="http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf", bibkey="web/Loader00") private static double stirlingError(double n)
Calculates the Stirling Errorstirlerr(n) = ln(n!) - ln(sqrt(2*pi*n)*(n/e)^n)
- Parameters:
n- Parameter n- Returns:
- Stirling error
-
devianceTerm
@Reference(title="Fast and accurate computation of binomial probabilities", authors="C. Loader", booktitle="", url="http://projects.scipy.org/scipy/raw-attachment/ticket/620/loader2000Fast.pdf", bibkey="web/Loader00") private static double devianceTerm(double x, double np)
Evaluate the deviance term of the saddle point approximation.bd0(x,np) = x*ln(x/np)+np-x
- Parameters:
x- probability density function positionnp- product of trials and success probability: n*p- Returns:
- Deviance term
-
rawProbability
public static double rawProbability(double x, double lambda)Poisson distribution probability, but also for non-integer arguments.lb^x exp(-lb) / x!
- Parameters:
x- Xlambda- lambda- Returns:
- Poisson distribution probability
-
rawLogProbability
public static double rawLogProbability(double x, double lambda)Poisson distribution probability, but also for non-integer arguments.lb^x exp(-lb) / x!
- Parameters:
x- Xlambda- lambda- Returns:
- Poisson distribution probability
-
toString
public java.lang.String toString()
Description copied from interface:DistributionDescribe the distribution- Specified by:
toStringin interfaceDistribution- Overrides:
toStringin classjava.lang.Object- Returns:
- description
-
-