Celeritas  0.5.0-56+6b053cd
Public Member Functions | List of all members
celeritas::ReciprocalDistribution< RealType > Class Template Reference

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.
 

Detailed Description

template<class RealType = ::celeritas::real_type>
class celeritas::ReciprocalDistribution< RealType >

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) \]

Constructor & Destructor Documentation

◆ ReciprocalDistribution() [1/2]

template<class RealType >
CELER_FUNCTION celeritas::ReciprocalDistribution< RealType >::ReciprocalDistribution ( real_type  a)
inlineexplicit

Construct on the interval [a, 1).

The distribution is equivalent to switching a and b, and using \( \xi' = 1 - \xi \).

◆ ReciprocalDistribution() [2/2]

template<class RealType >
CELER_FUNCTION celeritas::ReciprocalDistribution< RealType >::ReciprocalDistribution ( real_type  a,
real_type  b 
)
inline

Construct on the interval [a, b).

It is allowable for the two bounds to be out of order.

Note that writing as

(1/a) * b

allows the compiler to optimize better for the constexpr case a=1.


The documentation for this class was generated from the following file: