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...
 
UInt32 Poisson (Real f_mean)
 Returns a random value from a Poisson 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...
 
template<typename T >
void Shuffle (std::vector< T > &vec_data)
 Shuffles the values of the given vector in-place. 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

◆ CRNG() [1/2]

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.

◆ CRNG() [2/2]

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.

◆ ~CRNG()

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

Class destructor.

Definition at line 61 of file rng.cpp.

Member Function Documentation

◆ Bernoulli()

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.

◆ Exponential()

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.

◆ Gaussian()

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 152 of file rng.cpp.

◆ GetSeed()

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.

◆ Lognormal()

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 188 of file rng.cpp.

◆ Poisson()

UInt32 argos::CRandom::CRNG::Poisson ( Real  f_mean)

Returns a random value from a Poisson distribution.

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

Definition at line 131 of file rng.cpp.

◆ Rayleigh()

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 171 of file rng.cpp.

◆ Reset()

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

Reset the RNG.

Reset the RNG to the current seed value.

Definition at line 68 of file rng.cpp.

◆ SetSeed()

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.

◆ Shuffle()

template<typename T >
void argos::CRandom::CRNG::Shuffle ( std::vector< T > &  vec_data)
inline

Shuffles the values of the given vector in-place.

Parameters
vec_dataThe vector whose values must be shuffled.

Definition at line 214 of file rng.h.

◆ Uniform() [1/4]

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.

◆ Uniform() [2/4]

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.

◆ Uniform() [3/4]

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.

◆ Uniform() [4/4]

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.