Celeritas
0.5.0-56+6b053cd
|
Reciprocal or log-uniform distribution. More...
#include <ReciprocalDistribution.hh>
Public Types | |
Type aliases | |
using | real_type = RealType |
using | result_type = real_type |
Public Member Functions | |
CELER_FUNCTION | ReciprocalDistribution (real_type a) |
Construct on the interval [a, 1). More... | |
CELER_FUNCTION | ReciprocalDistribution (real_type a, real_type b) |
Construct on the interval [a, b). More... | |
template<class Generator > | |
CELER_FUNCTION result_type | operator() (Generator &rng) const |
template<class Generator > | |
CELER_FUNCTION auto | operator() (Generator &rng) const -> result_type |
Sample a random number according to the distribution. | |
Reciprocal or log-uniform distribution.
This distribution is defined on a positive range \( [a, b) \) and has the normalized PDF:
\[ f(x; a, b) = \frac{1}{x (\ln b - \ln a)} \quad \mathrm{for} \ a \le x < b \]
which integrated into a CDF and inverted gives a sample:
\[ x = a \left( \frac{b}{a} \right)^{\xi} = a \exp\!\left(\xi \log \frac{b}{a} \right) \]
|
inlineexplicit |
Construct on the interval [a, 1).
The distribution is equivalent to switching a and b, and using \( \xi' = 1 - \xi \).
|
inline |
Construct on the interval [a, b).
It is allowable for the two bounds to be out of order.
Note that writing as
allows the compiler to optimize better for the constexpr case a=1.