CVR-Lib last update 20 Sep 2009

cvr::randomDistribution Class Reference
[Random numbers]

Class randomDistribution. More...

#include <cvrRandomDistribution.h>

Inheritance diagram for cvr::randomDistribution:

Inheritance graph
[legend]
Collaboration diagram for cvr::randomDistribution:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class randomDistribution. More...
class  rndBase
 Pure virtual nested class base of all random number generators. More...
class  rndMersenneTwister
 Mersenne Twister Random Number Generator. More...
class  rndMinStd
 Linear Congruency Random Number Generator. More...
class  rndMinStd0
 Linear Congruency Random Number Generator. More...
class  rndStochastic
 Wrapper for <random> std::tr1::random_device, which is a hardware based true, unpredictable, random number generator. More...
class  rndSystem
 Wrapper for the <cstdlib> rand() function. More...

Public Types

enum  eNumberGenerator {
  SystemWide, Stochastic, MinStd, MinStd0,
  MT
}

Public Member Functions

 randomDistribution ()
 randomDistribution (const parameters &par)
 randomDistribution (const randomDistribution &other)
virtual ~randomDistribution ()
randomDistributioncopy (const randomDistribution &other)
randomDistributionoperator= (const randomDistribution &other)
virtual const std::string & name () const
virtual randomDistributionclone () const
virtual randomDistributionnewInstance () const
const parametersgetParameters () const
bool updateParameters ()
void setSeed (const uint32 newSeed)
virtual bool write (ioHandler &handler, const bool complete=true) const
virtual bool read (ioHandler &handler, const bool complete=true)

Protected Member Functions

parametersgetRWParameters ()

Protected Attributes

rndBasegenerator_
uint32 max_


Detailed Description

Class randomDistribution.

The class cvr::randomDistribution is the parent class of all random number generators in the CVR-Lib .

The concept followed in this library is complementary to the standard concept found in the STL <random> classes, which are employed within the classes of the present hierarchy. Since the std::tr1 classes are not implemented by all STL implementations, the CVR-Lib provides the required partial implementations for internal use only.

Note that the standard random number generators and distributions are highly template based, what makes them very efficient for execution time, but relatively hard to be dinamically configured. The present hierarchy is not intended as replacement of the standard concepts. It simply is a wrapper concept that allows the number generators to be configured dinamically, through the accustomed parameter objects, at the cost of reduced speed. In case you need the ultimative speed, then use the standard concept instead, or the original Boost Random Number Library (http://www.boost.org/libs/random/index.html), on which the standard relies. If you need runtime configuration capabilities, then the CVR-Lib concept is for you.

For image applications 32 bit precision is still sufficient. Hence, that is the precision you will get by the number generation of these distributions. This means that internally, the uniformly distributed number generator will produce numbers of type cvr::uint32.

See also:
randomDistribution::parameters.

Member Enumeration Documentation

Enumerator with the possible underlying uniformly distributed number generators.

Enumerator:
SystemWide  The system-wide random generator makes use of the old C-style rand() function, which is shared among all instances of classes derived from randomDistribution.
Stochastic  The stochastic method makes use of the device random generator, which is usually in "/dev/urandom".

It is a non-deterministic random number generator, usually implemented in the operating system, using highly entropic processes. Since it uses file I/O it is realtively slow.

MinStd  Linear congruential generator which uses $x_{n+1} = ( a x_{n} ) \mod m $ con $ a=16807 $ y $ m = 2147483647 $.

Therefore, the generated numbers are unsigned of 31 bit precision, and since m and c are relative primes, the repetition period equals m.

MinStd0  Linear congruential generator which uses $x_{n+1} = ( a x_{n} ) \mod m $ con $ a=48271 $ y $ m = 2147483647 $.

Therefore, the generated numbers are unsigned of 31 bit precision, and since m and c are relative primes, the repetition period equals m.

MT  Mersenne Twister random number generator.

The code for this generator is based on M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.

Check also the page http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html


Constructor & Destructor Documentation

cvr::randomDistribution::randomDistribution (  ) 

Default constructor.

cvr::randomDistribution::randomDistribution ( const parameters par  ) 

Construct a functor using the given parameters.

cvr::randomDistribution::randomDistribution ( const randomDistribution other  ) 

Copy constructor.

Parameters:
other the object to be copied

virtual cvr::randomDistribution::~randomDistribution (  )  [virtual]

Destructor.


Member Function Documentation

virtual randomDistribution* cvr::randomDistribution::clone (  )  const [virtual]

randomDistribution& cvr::randomDistribution::copy ( const randomDistribution other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

const parameters& cvr::randomDistribution::getParameters (  )  const

parameters& cvr::randomDistribution::getRWParameters (  )  [protected]

Returns read-writable reference to the internal parameters.

virtual const std::string& cvr::randomDistribution::name (  )  const [virtual]

virtual randomDistribution* cvr::randomDistribution::newInstance (  )  const [virtual]

randomDistribution& cvr::randomDistribution::operator= ( const randomDistribution other  ) 

Alias for copy member.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

virtual bool cvr::randomDistribution::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

Read the parameters from the given ioHandler.

Parameters:
handler the ioHandler to be used
complete if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written.
Returns:
true if write was successful

Reimplemented from cvr::functor.

void cvr::randomDistribution::setSeed ( const uint32  newSeed  ) 

Shortcut for changing the seed of the number generator.

Parameters:
newSeed new seed for the number generator.

bool cvr::randomDistribution::updateParameters (  )  [virtual]

virtual bool cvr::randomDistribution::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

Write the parameters in the given ioHandler.

Parameters:
handler the ioHandler to be used
complete if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written.
Returns:
true if write was successful

Reimplemented from cvr::functor.


Member Data Documentation

Pointer to the random number generator for float.

Maximum number obtainable in the generator.


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

Generated on Sun Sep 20 22:09:03 2009 for CVR-Lib by Doxygen 1.5.8