Celeritas
0.5.0-86+4a8eea4
|
Sample from an exponential distribution. More...
#include <ExponentialDistribution.hh>
Public Types | |
Type aliases | |
using | real_type = RealType |
using | result_type = RealType |
Public Member Functions | |
CELER_FUNCTION | ExponentialDistribution (real_type lambda=1) |
Construct from the mean of the exponential distribution. | |
template<class Generator > | |
CELER_FUNCTION result_type | operator() (Generator &g) |
template<class Generator > | |
CELER_FUNCTION auto | operator() (Generator &rng) -> result_type |
Sample a random number according to the distribution. | |
Sample from an exponential distribution.
Sample from a probability distribution function with the normalized PDF:
\[ f(x; \lambda) = \lambda e^{-\lambda x} \quad \mathrm{for} \ x >= 0 \]
which integrated into a CDF and inverted gives a sample:
\[ x = -\frac{\log \xi}{ \lambda} \]
This is simply an implementation of std::exponential_distribution that uses the Celeritas canonical generator and is independent of library implementation.
Note (for performance-critical sections of code) that if this class is constructed locally with the default value of lambda = 1.0, the inversion and multiplication will be optimized out.