public class PoissonDistribution extends AbstractDistribution
TODO: continue implementing, CDF, invcdf and nextRandom are missing
References:
Catherine Loader
Fast and Accurate Computation of Binomial Probabilities.
Modifier and Type | Class and Description |
---|---|
static class |
PoissonDistribution.Parameterizer
Parameterization class
|
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!
|
random
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.
|
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
|
private int n
private double p
private static final double S0
private static final double S1
private static final double S2
private static final double S3
private static final double S4
private static final double[] STIRLING_EXACT_ERROR
sfe[n] = ln( (n!*e^n)/((n^n)*sqrt(2*pi*n)) )
public PoissonDistribution(int n, double p)
n
- Number of triesp
- Success probabilitypublic PoissonDistribution(int n, double p, java.util.Random random)
n
- Number of triesp
- Success probabilityrandom
- Random generatorpublic PoissonDistribution(int n, double p, RandomFactory random)
n
- Number of triesp
- Success probabilityrandom
- Random generatorpublic double pmf(int x)
x
- integer valuespublic double pdf(double x)
Distribution
x
- existing valuepublic double logpdf(double x)
Distribution
x
- existing value@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)
x
- integer valuespublic static double logpmf(double x, int n, double p)
x
- integer valuespublic double cdf(double val)
Distribution
val
- existing valuepublic double quantile(double val)
Distribution
val
- Quantile to findpublic double nextRandom()
Distribution
nextRandom
in interface Distribution
nextRandom
in class AbstractDistribution
public static double poissonPDFm1(double x_plus_1, double lambda)
pdf(x_plus_1 - 1, lambda)
x_plus_1
- x+1lambda
- Lambdapublic static double logpoissonPDFm1(double x_plus_1, double lambda)
log pdf(x_plus_1 - 1, lambda)
x_plus_1
- x+1lambda
- Lambda@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)
stirlerr(n) = ln(n!) - ln(sqrt(2*pi*n)*(n/e)^n)
n
- Parameter n@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)
stirlerr(n) = ln(n!) - ln(sqrt(2*pi*n)*(n/e)^n)
n
- Parameter n@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)
bd0(x,np) = x*ln(x/np)+np-x
x
- probability density function positionnp
- product of trials and success probability: n*ppublic static double rawProbability(double x, double lambda)
lb^x exp(-lb) / x!
x
- Xlambda
- lambdapublic static double rawLogProbability(double x, double lambda)
lb^x exp(-lb) / x!
x
- Xlambda
- lambdapublic java.lang.String toString()
Distribution
toString
in interface Distribution
toString
in class java.lang.Object
Copyright © 2019 ELKI Development Team. License information.