ExRandom  3.0
exrandom::unit_exponential_dist< digit_gen, bit_optimized > Class Template Reference

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

#include <exrandom/unit_exponential_dist.hpp>

Public Member Functions

 unit_exponential_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, bool bit_optimized = true>
class exrandom::unit_exponential_dist< digit_gen, bit_optimized >

Sample u-rands exactly from the unit exponential distribution.

This samples from the unit exponential distribution P(x) = exp(−x) for x > 0. This implements Algorithms E and V.

Template Parameters
digit_genthe type of digit generator.
bit_optimizedif true use Algorithm E, else use Algorithm V.

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

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

If bit_optimized is true, digit_gen::base must be even.

Examples
count_bits.cpp, and sample_exponential.cpp.

Definition at line 43 of file unit_exponential_dist.hpp.

Constructor & Destructor Documentation

◆ unit_exponential_dist()

template<typename digit_gen, bool bit_optimized = true>
exrandom::unit_exponential_dist< digit_gen, bit_optimized >::unit_exponential_dist ( digit_gen &  D)
inline

The constructor.

Parameters
Da reference to the digit generator to be used.

Definition at line 50 of file unit_exponential_dist.hpp.

Member Function Documentation

◆ generate()

template<typename digit_gen, bool bit_optimized = true>
template<typename Generator >
void exrandom::unit_exponential_dist< digit_gen, bit_optimized >::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 60 of file unit_exponential_dist.hpp.

◆ value()

template<typename digit_gen, bool bit_optimized = true>
template<typename RealType , typename Generator >
RealType exrandom::unit_exponential_dist< digit_gen, bit_optimized >::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 exponential deviate.

Definition at line 83 of file unit_exponential_dist.hpp.

◆ digit_generator()

template<typename digit_gen, bool bit_optimized = true>
digit_gen& exrandom::unit_exponential_dist< digit_gen, bit_optimized >::digit_generator ( ) const
inline
Returns
a reference to the digit generator used in the constructor.

Definition at line 91 of file unit_exponential_dist.hpp.

Member Data Documentation

◆ base

template<typename digit_gen, bool bit_optimized = true>
const uint_t exrandom::unit_exponential_dist< digit_gen, bit_optimized >::base
static

The base of the digit generator.

Definition at line 96 of file unit_exponential_dist.hpp.


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