koho.cpp  1.1.0
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
koho::RandomState Class Reference

A random number generator. More...

#include <random_number_generator.h>

Public Member Functions

 RandomState ()
 Create and initialize random number generator with the current system time. More...
 
 RandomState (unsigned long seed)
 Create and initialize random number generator with a seed. More...
 
double uniform_real (double low, double high)
 Provide a double random number from a uniform distribution between [low, high). More...
 
long uniform_int (long low, long high)
 Provide a long random number from a uniform distribution between [low, high). More...
 

Static Public Attributes

static const long MAX_INT = std::numeric_limits<long>::max()
 Upper bound for long random numbers [..., high). More...
 

Protected Attributes

std::mt19937 eng
 Mersenne twister. More...
 

Detailed Description

A random number generator.

Constructor & Destructor Documentation

◆ RandomState() [1/2]

koho::RandomState::RandomState ( )

Create and initialize random number generator with the current system time.

◆ RandomState() [2/2]

koho::RandomState::RandomState ( unsigned long  seed)

Create and initialize random number generator with a seed.

Parameters
[in]seed

Member Function Documentation

◆ uniform_int()

long koho::RandomState::uniform_int ( long  low,
long  high 
)

Provide a long random number from a uniform distribution between [low, high).

Parameters
[in]lowincluded lower bound for random number.
[in]highexcluded upper bound for random number.
Returns
random number.

◆ uniform_real()

double koho::RandomState::uniform_real ( double  low,
double  high 
)

Provide a double random number from a uniform distribution between [low, high).

Parameters
[in]lowincluded lower bound for random number.
[in]highexcluded upper bound for random number.
Returns
random number.

Member Data Documentation

◆ eng

std::mt19937 koho::RandomState::eng
protected

Mersenne twister.

◆ MAX_INT

const long koho::RandomState::MAX_INT = std::numeric_limits<long>::max()
static

Upper bound for long random numbers [..., high).


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