Celeritas 0.6.0-2+develop.96611fab
Loading...
Searching...
No Matches
Public Member Functions | List of all members
celeritas::UniformRealDistribution< RealType > Class Template Reference

Sample from a uniform distribution. More...

#include <UniformRealDistribution.hh>

Public Types

Type aliases
using real_type = RealType
 
using result_type = real_type
 

Public Member Functions

CELER_CONSTEXPR_FUNCTION UniformRealDistribution ()
 Construct on the interval [0, 1).
 
CELER_CONSTEXPR_FUNCTION UniformRealDistribution (real_type a, real_type b)
 Construct on the interval [a, b).
 
template<class Generator >
CELER_FUNCTION result_type operator() (Generator &rng) const
 
CELER_CONSTEXPR_FUNCTION real_type a () const
 Get the lower bound of the distribution.
 
CELER_CONSTEXPR_FUNCTION real_type b () const
 Get the upper bound of the distribution.
 
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::UniformRealDistribution< RealType >

Sample from a uniform distribution.

This distribution is defined between two arbitrary real numbers a and b , and has a flat PDF between the two values. It is allowable for the two numbers to have reversed order. The normalized PDF is:

\[ f(x; a, b) = \frac{1}{b - a} \quad \mathrm{for} \ a \le x < b \]

which integrated into a CDF and inverted gives a sample:

\[ x = (b - a) \xi + a \]

Constructor & Destructor Documentation

◆ UniformRealDistribution() [1/2]

Construct on the interval [0, 1).

This constructor is generally unused because it's simpler and more efficient to directly call generate_canonical. We leave it for compatibility with the standard.

◆ UniformRealDistribution() [2/2]

template<class RealType >
CELER_CONSTEXPR_FUNCTION celeritas::UniformRealDistribution< RealType >::UniformRealDistribution ( real_type  a,
real_type  b 
)

Construct on the interval [a, b).

Note that it's allowable for these two to be out of order to support other generators (inverse square, power) where they may be inverted and out of order.


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