de.lmu.ifi.dbs.elki.math.statistics.distribution

## Class PoissonDistribution

• All Implemented Interfaces:
Distribution

public class PoissonDistribution
extends AbstractDistribution
INCOMPLETE implementation of the poisson distribution.

TODO: continue implementing, CDF, invcdf and nextRandom are missing

References:

Fast and Accurate Computation of Binomial Probabilities.

Since:
0.5.0
Author:
Erich Schubert
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  PoissonDistribution.Parameterizer
Parameterization class
• ### Field Summary

Fields
Modifier and Type Field and Description
private int n
Number of tries
private double p
Success probability
private static double S0
Stirling error constants: 1./12
private static double S1
Stirling error constants: 1./360
private static double S2
Stirling error constants: 1./1260
private static double S3
Stirling error constants: 1./1680
private static double S4
Stirling error constants: 1./1188
private static double[] STIRLING_EXACT_ERROR
Exact table values for n <= 15 in steps of 0.5 sfe[n] = ln( (n!
• ### Fields inherited from class de.lmu.ifi.dbs.elki.math.statistics.distribution.AbstractDistribution

random
• ### Constructor Summary

Constructors
Constructor and Description
PoissonDistribution(int n, double p)
Constructor.
PoissonDistribution(int n, double p, java.util.Random random)
Constructor.
PoissonDistribution(int n, double p, RandomFactory random)
Constructor.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double cdf(double val)
Return the cumulative density function at the given value.
private static double devianceTerm(double x, double np)
Evaluate the deviance term of the saddle point approximation.
double logpdf(double x)
Return the log density of an existing value
static double logpmf(double x, int n, double p)
Poisson probability mass function (PMF) for integer values.
static double logpoissonPDFm1(double x_plus_1, double lambda)
Compute the poisson distribution PDF with an offset of + 1 log pdf(x_plus_1 - 1, lambda)
double nextRandom()
Generate a new random value
double pdf(double x)
Return the density of an existing value
static double pmf(double x, int n, double p)
Poisson probability mass function (PMF) for integer values.
double pmf(int x)
Poisson probability mass function (PMF) for integer values.
static double poissonPDFm1(double x_plus_1, double lambda)
Compute the poisson distribution PDF with an offset of + 1 pdf(x_plus_1 - 1, lambda)
double quantile(double val)
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.
static double rawLogProbability(double x, double lambda)
Poisson distribution probability, but also for non-integer arguments.
static double rawProbability(double x, double lambda)
Poisson distribution probability, but also for non-integer arguments.
private static double stirlingError(double n)
Calculates the Stirling Error stirlerr(n) = ln(n!)
private static double stirlingError(int n)
Calculates the Stirling Error stirlerr(n) = ln(n!)
java.lang.String toString()
Describe the distribution
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
• ### 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
Constant Field Values
• #### S1

private static final double S1
Stirling error constants: 1./360
Constant Field Values
• #### S2

private static final double S2
Stirling error constants: 1./1260
Constant Field Values
• #### S3

private static final double S3
Stirling error constants: 1./1680
Constant Field Values
• #### S4

private static final double S4
Stirling error constants: 1./1188
Constant Field Values
• #### STIRLING_EXACT_ERROR

private static final double[] STIRLING_EXACT_ERROR
Exact table values for n <= 15 in steps of 0.5

sfe[n] = ln( (n!*e^n)/((n^n)*sqrt(2*pi*n)) )

• ### Constructor Detail

• #### PoissonDistribution

public PoissonDistribution(int n,
double p)
Constructor.
Parameters:
n - Number of tries
p - Success probability
• #### PoissonDistribution

public PoissonDistribution(int n,
double p,
java.util.Random random)
Constructor.
Parameters:
n - Number of tries
p - Success probability
random - Random generator
• #### PoissonDistribution

public PoissonDistribution(int n,
double p,
RandomFactory random)
Constructor.
Parameters:
n - Number of tries
p - Success probability
random - Random generator
• ### 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: Distribution
Return the density of an existing value
Parameters:
x - existing value
Returns:
distribution density
• #### logpdf

public double logpdf(double x)
Description copied from interface: Distribution
Return the log density of an existing value
Parameters:
x - existing value
Returns:
log distribution density
• #### pmf

@Reference(title="Fast and accurate computation of binomial probabilities",
booktitle="",
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: Distribution
Return the cumulative density function at the given value.
Parameters:
val - existing value
Returns:
cumulative density
• #### quantile

public double quantile(double val)
Description copied from interface: Distribution
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.
Parameters:
val - Quantile to find
Returns:
Quantile position
• #### nextRandom

public double nextRandom()
Description copied from interface: Distribution
Generate a new random value
Specified by:
nextRandom in interface Distribution
Overrides:
nextRandom in class AbstractDistribution
Returns:
new random value
• #### poissonPDFm1

public static double poissonPDFm1(double x_plus_1,
double lambda)
Compute the poisson distribution PDF with an offset of + 1

pdf(x_plus_1 - 1, lambda)

Parameters:
x_plus_1 - x+1
lambda - Lambda
Returns:
pdf
• #### logpoissonPDFm1

public static double logpoissonPDFm1(double x_plus_1,
double lambda)
Compute the poisson distribution PDF with an offset of + 1

log pdf(x_plus_1 - 1, lambda)

Parameters:
x_plus_1 - x+1
lambda - Lambda
Returns:
pdf
• #### stirlingError

@Reference(title="Fast and accurate computation of binomial probabilities",
booktitle="",
private static double stirlingError(int n)
Calculates the Stirling Error

stirlerr(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",
booktitle="",
private static double stirlingError(double n)
Calculates the Stirling Error

stirlerr(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",
booktitle="",
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 position
np - 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 - X
lambda - 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 - X
lambda - lambda
Returns:
Poisson distribution probability
• #### toString

public java.lang.String toString()
Description copied from interface: Distribution
Describe the distribution
Specified by:
toString in interface Distribution
Overrides:
toString in class java.lang.Object
Returns:
description