bpp-core  2.2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
bpp::Uniform01K Class Reference

A uniform random number generator. More...

#include <Bpp/Numeric/Random/Uniform01K.h>

+ Inheritance diagram for bpp::Uniform01K:
+ Collaboration diagram for bpp::Uniform01K:

Public Member Functions

 Uniform01K (long seed)
 Create a Random Number Generator. More...
 
virtual ~Uniform01K ()
 Destroy the generator. More...
 
void setSeed (long seed)
 Set the seed for a new set of random numbers. More...
 
double drawNumber () const
 Get a random number between 0.0 and 1.0 (exclusive of the end point values). More...
 

Private Attributes

long _tab [56]
 
unsigned int _it1
 
unsigned int _it2
 

Static Private Attributes

static const long MAXNUMBER = 1000000000
 
static const long ZERO = 0
 
static const long MODSEED = 256434901
 

Detailed Description

A uniform random number generator.

This is a uniform generator which draw double between 0 and 1 excluding the end points. This generator is based on an algorithm described by D.E. Knuth, 1981, "Seminumerical Algorithms" 2nd ed., vol.2 of "The Art of Computer Programming" (Reading, MA: Addison-Wesley), ยงยง3.2-3.3.

The algorithm used here is the one described in "Numerical Recipes in C".

Definition at line 59 of file Uniform01K.h.

Constructor & Destructor Documentation

Uniform01K::Uniform01K ( long  seed)

Create a Random Number Generator.

Parameters
seedThe seed for the random numbers.

Definition at line 52 of file Uniform01K.cpp.

References setSeed().

Uniform01K::~Uniform01K ( )
virtual

Destroy the generator.

Definition at line 59 of file Uniform01K.cpp.

Member Function Documentation

double Uniform01K::drawNumber ( ) const
virtual

Get a random number between 0.0 and 1.0 (exclusive of the end point values).

Implements bpp::RandomFactory.

Definition at line 93 of file Uniform01K.cpp.

References _it1, _it2, _tab, MAXNUMBER, and ZERO.

void Uniform01K::setSeed ( long  seed)
virtual

Set the seed for a new set of random numbers.

Implements bpp::RandomFactory.

Definition at line 63 of file Uniform01K.cpp.

References _it1, _it2, _tab, bpp::NumTools::abs(), MAXNUMBER, MODSEED, and ZERO.

Referenced by Uniform01K().

Member Data Documentation

unsigned int bpp::Uniform01K::_it1
mutableprivate

Definition at line 90 of file Uniform01K.h.

Referenced by drawNumber(), and setSeed().

unsigned int bpp::Uniform01K::_it2
mutableprivate

Definition at line 91 of file Uniform01K.h.

Referenced by drawNumber(), and setSeed().

long bpp::Uniform01K::_tab[56]
mutableprivate

Definition at line 89 of file Uniform01K.h.

Referenced by drawNumber(), and setSeed().

const long Uniform01K::MAXNUMBER = 1000000000
staticprivate

Definition at line 86 of file Uniform01K.h.

Referenced by drawNumber(), and setSeed().

const long Uniform01K::MODSEED = 256434901
staticprivate

Definition at line 88 of file Uniform01K.h.

Referenced by setSeed().

const long Uniform01K::ZERO = 0
staticprivate

Definition at line 87 of file Uniform01K.h.

Referenced by drawNumber(), and setSeed().


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