Celeritas  0.5.0-86+4a8eea4
Public Member Functions | List of all members
celeritas::NormalDistribution< RealType > Class Template Reference

Sample from a normal distribution. More...

#include <NormalDistribution.hh>

Public Types

Type aliases
using real_type = RealType
 
using result_type = real_type
 

Public Member Functions

CELER_FUNCTION NormalDistribution (real_type mean, real_type stddev)
 Construct with mean and standard deviation.
 
CELER_FUNCTION NormalDistribution (real_type mean)
 Construct with unit deviation.
 
CELER_FUNCTION NormalDistribution ()
 Construct with unit deviation and zero mean.
 
CELER_FUNCTION NormalDistribution (NormalDistribution const &other)
 Initialize with parameters but not spare values.
 
CELER_FUNCTION NormalDistribution (NormalDistribution &&other) noexcept
 Reset spare value of other distribution.
 
CELER_FUNCTION NormalDistributionoperator= (NormalDistribution const &)
 Keep spare value but change distribution.
 
CELER_FUNCTION NormalDistributionoperator= (NormalDistribution &&) noexcept
 Possibly use spare value, change distribution.
 
template<class Generator >
CELER_FUNCTION result_type operator() (Generator &rng)
 
template<class Generator >
CELER_FUNCTION auto operator() (Generator &rng) -> result_type
 Sample a random number according to the distribution.
 

Detailed Description

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

Sample from a normal distribution.

This uses the Box-Muller transform to generate pairs of independent, normally distributed random numbers, returning them one at a time. Two random numbers uniformly distributed on [0, 1] are mapped to two independent, standard, normally distributed samples using the relations:

\[ x_1 = \sqrt{-2 \ln \xi_1} \cos(2 \pi \xi_2) x_2 = \sqrt{-2 \ln \xi_1} \sin(2 \pi \xi_2) \]


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