ExRandom  3.0
exrandom::unit_normal_dist< digit_gen > Class Template Reference

Sample u-rands exactly from the unit normal distribution. More...

#include <exrandom/unit_normal_dist.hpp>

Public Member Functions

 unit_normal_dist (digit_gen &D)
 
template<typename Generator >
void generate (Generator &g, u_rand< digit_gen > &x)
 
template<typename RealType , typename Generator >
RealType value (Generator &g)
 
digit_gen & digit_generator () const
 

Static Public Attributes

static const uint_t base
 

Detailed Description

template<typename digit_gen>
class exrandom::unit_normal_dist< digit_gen >

Sample u-rands exactly from the unit normal distribution.

This samples from the unit normal distribution P(x) = exp(− x2/2) / √(2π). This implements Algorithm N with improvements due to Du et al. (2020).

Template Parameters
digit_genthe type of digit generator.

This class allows a u-rand to be returned via the unit_normal_dist::generate member function or a floating point result via the unit_normal_dist::value<RealType> member function.

See unit_normal_distribution for a simpler interface to sampling normal deviates. (But, you can't obtain u-rands with this class and the constructor locks you into a specific floating point type.)

Examples
count_bits.cpp, hist_data.cpp, sample_normal.cpp, and tabulate_normals.cpp.

Definition at line 36 of file unit_normal_dist.hpp.

Constructor & Destructor Documentation

◆ unit_normal_dist()

template<typename digit_gen>
exrandom::unit_normal_dist< digit_gen >::unit_normal_dist ( digit_gen &  D)
inline

The constructor.

Parameters
Da reference to the digit generator to be used.

Definition at line 43 of file unit_normal_dist.hpp.

Member Function Documentation

◆ generate()

template<typename digit_gen>
template<typename Generator >
void exrandom::unit_normal_dist< digit_gen >::generate ( Generator &  g,
u_rand< digit_gen > &  x 
)
inline

Generate the next deviate as a u_rand.

Template Parameters
Generatorthe type of g.
Parameters
gthe random generator engine.
[out]xthe u_rand to set.

Definition at line 53 of file unit_normal_dist.hpp.

◆ value()

template<typename digit_gen>
template<typename RealType , typename Generator >
RealType exrandom::unit_normal_dist< digit_gen >::value ( Generator &  g)
inline

Generate the next deviate and round it to a floating point number.

Template Parameters
RealTypethe floating point type of the result.
Generatorthe type of g.
Parameters
gthe random generator engine.
Returns
the normal deviate.

Definition at line 76 of file unit_normal_dist.hpp.

◆ digit_generator()

template<typename digit_gen>
digit_gen& exrandom::unit_normal_dist< digit_gen >::digit_generator ( ) const
inline
Returns
a reference to the digit generator used in the constructor.

Definition at line 84 of file unit_normal_dist.hpp.

Member Data Documentation

◆ base

template<typename digit_gen>
const uint_t exrandom::unit_normal_dist< digit_gen >::base
static

The base of the digit generator.

Definition at line 89 of file unit_normal_dist.hpp.


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