QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
LecuyerUniformRng Class Reference

Uniform random number generator. More...

#include <lecuyeruniformrng.hpp>

+ Collaboration diagram for LecuyerUniformRng:

Public Types

typedef Sample< Realsample_type
 

Public Member Functions

 LecuyerUniformRng (long seed=0)
 
sample_type next () const
 

Private Attributes

long temp1
 
long temp2
 
long y
 
std::vector< long > buffer
 

Static Private Attributes

static const long m1 = 2147483563L
 
static const long a1 = 40014L
 
static const long q1 = 53668L
 
static const long r1 = 12211L
 
static const long m2 = 2147483399L
 
static const long a2 = 40692L
 
static const long q2 = 52774L
 
static const long r2 = 3791L
 
static const int bufferSize = 32
 
static const long bufferNormalizer = 67108862L
 
static const long double maxRandom = 1.0-QL_EPSILON
 

Detailed Description

Uniform random number generator.

Random number generator of L'Ecuyer with added Bays-Durham shuffle (know as ran2 in Numerical recipes)

For more details see Section 7.1 of Numerical Recipes in C, 2nd Edition, Cambridge University Press (available at http://www.nr.com/)

Definition at line 40 of file lecuyeruniformrng.hpp.

Member Typedef Documentation

◆ sample_type

Definition at line 42 of file lecuyeruniformrng.hpp.

Constructor & Destructor Documentation

◆ LecuyerUniformRng()

LecuyerUniformRng ( long  seed = 0)
explicit

if the given seed is 0, a random seed will be chosen based on clock()

Definition at line 42 of file lecuyeruniformrng.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ next()

returns a sample with weight 1.0 containing a random number uniformly chosen from (0.0,1.0)

Definition at line 58 of file lecuyeruniformrng.cpp.

Member Data Documentation

◆ temp1

long temp1
mutableprivate

Definition at line 50 of file lecuyeruniformrng.hpp.

◆ temp2

long temp2
private

Definition at line 50 of file lecuyeruniformrng.hpp.

◆ y

long y
mutableprivate

Definition at line 51 of file lecuyeruniformrng.hpp.

◆ buffer

std::vector<long> buffer
mutableprivate

Definition at line 52 of file lecuyeruniformrng.hpp.

◆ m1

const long m1 = 2147483563L
staticprivate

Definition at line 53 of file lecuyeruniformrng.hpp.

◆ a1

const long a1 = 40014L
staticprivate

Definition at line 54 of file lecuyeruniformrng.hpp.

◆ q1

const long q1 = 53668L
staticprivate

Definition at line 55 of file lecuyeruniformrng.hpp.

◆ r1

const long r1 = 12211L
staticprivate

Definition at line 56 of file lecuyeruniformrng.hpp.

◆ m2

const long m2 = 2147483399L
staticprivate

Definition at line 57 of file lecuyeruniformrng.hpp.

◆ a2

const long a2 = 40692L
staticprivate

Definition at line 58 of file lecuyeruniformrng.hpp.

◆ q2

const long q2 = 52774L
staticprivate

Definition at line 59 of file lecuyeruniformrng.hpp.

◆ r2

const long r2 = 3791L
staticprivate

Definition at line 60 of file lecuyeruniformrng.hpp.

◆ bufferSize

const int bufferSize = 32
staticprivate

Definition at line 61 of file lecuyeruniformrng.hpp.

◆ bufferNormalizer

const long bufferNormalizer = 67108862L
staticprivate

Definition at line 62 of file lecuyeruniformrng.hpp.

◆ maxRandom

const long double maxRandom = 1.0-QL_EPSILON
staticprivate

Definition at line 63 of file lecuyeruniformrng.hpp.