Celeritas 0.7.0-dev.245+develop.a7be925e
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

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

template<class RealType >
constexpr celeritas::UniformRealDistribution< RealType >::UniformRealDistribution ( )
inlineconstexpr

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 >
constexpr celeritas::UniformRealDistribution< RealType >::UniformRealDistribution ( real_type  a,
real_type  b 
)
inlineconstexpr

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: