Poisson¶
Description¶
Calculates the Poisson loglikelihood function value.
Inputs¶
Theory \(\mu\) of size \(N\).
Data \(x\) of size \(N\).
Optionally \(\mu_2,x_2,\dots\) of sizes \(N_2,\dots\).
Inputs are added via add(theory, data)
method.
Outputs¶
'poisson'
— -2 Poisson loglikelihood function value.
Implementation¶
Formula for Poisson likelihood:
\[L(x|\mu) = \prod_{i=1}^{N} \frac {(\mu_i^{x_i} e^{-\mu_i})}{x_i!}\]
In source code there is used the natural logarithm of \(L(x|\mu)\), so formula is
\[\log L(x|\mu) = \sum_{i=1}^{N} {(x_i \log(\mu_i) - \mu_i - log(x_i!))}\]
where \(N\) is a size vectors \(\mu\) and \(x\)
In the third part of this sum there is \(x!\) - the function that increase so fast and can cause overflow.
There are two ways to deal with it. By default the program uses natural logarithm of Gamma function:
\[\Gamma(x) = (x - 1)!\]
It also can be used the following approximation
\[\log(x!) \approx x log(x) - x\]
You have to add --ln-approx
parameter in python script to apply it.