argos::CRandom::CRNG Class Reference

The RNG. More...

#include <rng.h>

Public Member Functions

 CRNG (UInt32 un_seed)
 Class constructor. More...
 
 CRNG (const CRNG &c_rng)
 Class copy constructor. More...
 
virtual ~CRNG ()
 Class destructor. More...
 
UInt32 GetSeed () const throw ()
 Returns the seed of this RNG. More...
 
void SetSeed (UInt32 un_seed) throw ()
 Sets the seed of this RNG. More...
 
void Reset ()
 Reset the RNG. More...
 
bool Bernoulli (Real f_true=0.5)
 Returns a random value from a Bernoulli distribution. More...
 
CRadians Uniform (const CRange< CRadians > &c_range)
 Returns a random value from a uniform distribution. More...
 
Real Uniform (const CRange< Real > &c_range)
 Returns a random value from a uniform distribution. More...
 
SInt32 Uniform (const CRange< SInt32 > &c_range)
 Returns a random value from a uniform distribution. More...
 
UInt32 Uniform (const CRange< UInt32 > &c_range)
 Returns a random value from a uniform distribution. More...
 
Real Exponential (Real f_mean)
 Returns a random value from an exponential distribution. More...
 
Real Gaussian (Real f_std_dev, Real f_mean=0.0f)
 Returns a random value from a Gaussian distribution. More...
 
Real Rayleigh (Real f_sigma)
 Returns a random value from a Rayleigh distribution. More...
 
Real Lognormal (Real f_sigma, Real f_mu)
 Returns a random value from a Lognormal distribution. More...
 

Detailed Description

The RNG.

This class is the real random number generator. You need an instance of this class to be able to generate random numbers.

Definition at line 90 of file rng.h.

Constructor & Destructor Documentation

argos::CRandom::CRNG::CRNG ( UInt32  un_seed)

Class constructor.

To create a new RNG from user code, never use this method. Use CreateRNG() instead.

Parameters
un_seedthe seed of the RNG.
str_typethe type of RNG to use. By default, Mersenne Twister is used. For a list of available RNG types, see GetRNGTypes().

Definition at line 41 of file rng.cpp.

argos::CRandom::CRNG::CRNG ( const CRNG c_rng)

Class copy constructor.

To create a new RNG from user code, never use this method. Use CreateRNG() instead.

Definition at line 51 of file rng.cpp.

argos::CRandom::CRNG::~CRNG ( )
virtual

Class destructor.

Definition at line 61 of file rng.cpp.

Member Function Documentation

bool argos::CRandom::CRNG::Bernoulli ( Real  f_true = 0.5)

Returns a random value from a Bernoulli distribution.

Parameters
f_truethe probability to return a 1.
Returns
a random value from a Bernoulli distribution (true/false).

Definition at line 80 of file rng.cpp.

Real argos::CRandom::CRNG::Exponential ( Real  f_mean)

Returns a random value from an exponential distribution.

Parameters
f_meanthe mean of the exponential distribution.
Returns
a random value from an exponential distribution.

Definition at line 123 of file rng.cpp.

Real argos::CRandom::CRNG::Gaussian ( Real  f_std_dev,
Real  f_mean = 0.0f 
)

Returns a random value from a Gaussian distribution.

Parameters
f_std_devthe standard deviation of the Gaussian distribution.
f_meanthe mean of the Gaussian distribution.
Returns
a random value from the Gaussian distribution.

Definition at line 131 of file rng.cpp.

UInt32 argos::CRandom::CRNG::GetSeed ( ) const
throw (
)
inline

Returns the seed of this RNG.

Returns
the seed of this RNG.

Definition at line 117 of file rng.h.

Real argos::CRandom::CRNG::Lognormal ( Real  f_sigma,
Real  f_mu 
)

Returns a random value from a Lognormal distribution.

Parameters
f_sigmaparameter sigma of the distribution
f_muparameter mu of the distribution
Returns
a random value from the Lognormal distribution.

Definition at line 167 of file rng.cpp.

Real argos::CRandom::CRNG::Rayleigh ( Real  f_sigma)

Returns a random value from a Rayleigh distribution.

Parameters
f_sigmaparameter sigma of the distribution
Returns
a random value from the Rayleigh distribution.

Definition at line 150 of file rng.cpp.

void argos::CRandom::CRNG::Reset ( )

Reset the RNG.

Reset the RNG to the current seed value.

Definition at line 68 of file rng.cpp.

void argos::CRandom::CRNG::SetSeed ( UInt32  un_seed)
throw (
)
inline

Sets the seed of this RNG.

This method does not reset the RNG. You must call Reset() explicitly.

Parameters
un_seedthe new seed for this RNG.
See also
Reset()

Definition at line 127 of file rng.h.

CRadians argos::CRandom::CRNG::Uniform ( const CRange< CRadians > &  c_range)

Returns a random value from a uniform distribution.

Parameters
c_rangethe range of values to draw one from.
Returns
a random value from the range [min,max).

Definition at line 87 of file rng.cpp.

Real argos::CRandom::CRNG::Uniform ( const CRange< Real > &  c_range)

Returns a random value from a uniform distribution.

Parameters
c_rangethe range of values to draw one from.
Returns
a random value from the range [min,max).

Definition at line 96 of file rng.cpp.

SInt32 argos::CRandom::CRNG::Uniform ( const CRange< SInt32 > &  c_range)

Returns a random value from a uniform distribution.

Parameters
c_rangethe range of values to draw one from.
Returns
a random value from the range [min,max).

Definition at line 105 of file rng.cpp.

UInt32 argos::CRandom::CRNG::Uniform ( const CRange< UInt32 > &  c_range)

Returns a random value from a uniform distribution.

Parameters
c_rangethe range of values to draw one from.
Returns
a random value from the range [min,max).

Definition at line 114 of file rng.cpp.