Celeritas
0.5.0-56+6b053cd
|
Sample from a Poisson distribution. More...
#include <PoissonDistribution.hh>
Public Types | |
Type aliases | |
using | real_type = RealType |
using | result_type = unsigned int |
Public Member Functions | |
CELER_FUNCTION | PoissonDistribution (real_type lambda=1) |
Construct from the mean of the Poisson distribution. | |
template<class Generator > | |
CELER_FUNCTION result_type | operator() (Generator &rng) |
template<class Generator > | |
CELER_FUNCTION auto | operator() (Generator &rng) -> result_type |
Sample a random number according to the distribution. | |
Static Public Member Functions | |
static CELER_CONSTEXPR_FUNCTION int | lambda_threshold () |
Maximum value of lambda for using the direct method. | |
Sample from a Poisson distribution.
The Poisson distribution describes the probability of \( k \) events occuring in a fixed interval given a mean rate of occurance \( \lambda \) and has the PMF:
\[ f(k; \lambda) = \frac{\lambda^k e^{-\lambda}}{k!} \:. \]
For small \( \lambda \), a direct method described in Knuth, Donald E., Seminumerical Algorithms, The Art of Computer Programming, Volume 2 can be used to generate samples from the Poisson distribution. Uniformly distributed random numbers are generated until the relation
\[ \prod_{k = 1}^n U_k \le e^{-\lambda} \]
is satisfied; then, the random variable \( X = n - 1 \) will have a Poisson distribution. On average this approach requires the generation of \( \lambda + 1 \) uniform random samples, so a different method should be used for large \( \lambda \).
Geant4 uses Knuth's algorithm for \( \lambda \le 16 \) and a Gaussian approximation for \( \lambda > 16 \) (see G4Poisson
), which is faster but less accurate than other methods. The same approach is used here.