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

Sample u-rands from the normal distribution, Kahn's method (deprecated) More...

#include <exrandom/unit_normal_kahn.hpp>

Public Member Functions

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

Static Public Attributes

static const uint_t base
 

Detailed Description

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

Sample u-rands from the normal distribution, Kahn's method (deprecated)

This samples from the unit normal distribution P(x) = exp(− x2/2) / √(2π) using Kahn's method This implements Algorithm K.

Template Parameters
digit_genthe type of digit generator.

WARNING: One of the steps of this algorithm requires the use of arbitrary precision integer arithmetic. However in this implementation the arithmetic is carried out with 64-bit integers. As a result there is occasionally (1 time in 109) overflow which results in a bias in the results. Use of this class is therefore deprecated.

digit_gen::base cannot exceed 16.

Examples
count_bits.cpp.

Definition at line 38 of file unit_normal_kahn.hpp.

Constructor & Destructor Documentation

◆ unit_normal_kahn()

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

The constructor.

Parameters
Da reference to the digit generator to be used.

Definition at line 45 of file unit_normal_kahn.hpp.

Member Function Documentation

◆ generate()

template<typename digit_gen>
template<typename Generator >
void exrandom::unit_normal_kahn< 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 55 of file unit_normal_kahn.hpp.

◆ value()

template<typename digit_gen>
template<typename RealType , typename Generator >
RealType exrandom::unit_normal_kahn< 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 116 of file unit_normal_kahn.hpp.

◆ midpoint()

template<typename digit_gen>
template<typename RealType , typename Generator >
RealType exrandom::unit_normal_kahn< digit_gen >::midpoint ( Generator &  g,
size_t  k 
)
inline

Return the midpoint of the next deviate with a specified number of digits.

Template Parameters
RealTypethe floating point type of the result.
Generatorthe type of g.
Parameters
gthe random generator engine.
kthe minimum number of digits in the fraction.
Returns
the normal deviate.

Note the k gives the numer of digits in the base base.

Definition at line 134 of file unit_normal_kahn.hpp.

◆ digit_generator()

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

Definition at line 142 of file unit_normal_kahn.hpp.

Member Data Documentation

◆ base

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

The base of the digit generator.

Definition at line 147 of file unit_normal_kahn.hpp.


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