Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::Random Class Reference

#include <Random.h>

List of all members.


Detailed Description

A class for generating random numbers and performing randomization operations.

Before any random operations are performed, it is advisable to call the static init() method.


Static Public Methods

double uniform ()
 Get a double-precision number from a uniformly distributed source of pseudo-random numbers.

double uniform (double min, double max)
 Get a double-precision number from a uniformly distributed source of pseudo-random numbers.

double uniform (double upperBound)
 Get a double-precision number from a uniformly distributed source of pseudo-random numbers.

long uniform (long upperBound)
 Get a pseudo-random, uniformly distributed integer.

double gaussian ()
 Get a double-precision pseudo-random number from a Gaussian distribution with zero mean and unit variance.

double gaussian (double mean, double std)
 Get a double-precision pseudo-random number from a Gaussian distribution with the given mean and standard deviation.

void init ()
 Initialize the random number generator from system clock.

void init (long seed)
 Initialize the random number generator with your favourite value.

template<class T> void shuffle (util::List< T > &lst)
 Rearrange the elements in lst in a random way.


Member Function Documentation

double prapi::Random::gaussian double    mean,
double    std
[inline, static]
 

Get a double-precision pseudo-random number from a Gaussian distribution with the given mean and standard deviation.

Returns:
a pseudo-random number from a Gaussian source.

double prapi::Random::gaussian   [static]
 

Get a double-precision pseudo-random number from a Gaussian distribution with zero mean and unit variance.

Returns:
a pseudo-random number from a N(0,1) source.

void prapi::Random::init   [inline, static]
 

Initialize the random number generator from system clock.

Note that successive inits within the same second have no effect. Note also that this method must be called before any random numbers are generated if you don't want a similar sequence each time the program is run.

template<class T>
void prapi::Random::shuffle util::List< T > &    lst [static]
 

Rearrange the elements in lst in a random way.

Parameters:
lst  the list to be shuffled

long prapi::Random::uniform long    upperBound [inline, static]
 

Get a pseudo-random, uniformly distributed integer.

Returns:
a pseudo-random integer in the range [0,upperBound-1]

double prapi::Random::uniform double    upperBound [inline, static]
 

Get a double-precision number from a uniformly distributed source of pseudo-random numbers.

Returns:
a pseudo-random number in the range [0,upperBound)

double prapi::Random::uniform double    min,
double    max
[inline, static]
 

Get a double-precision number from a uniformly distributed source of pseudo-random numbers.

Returns:
a pseudo-random number in the range [min,max]

double prapi::Random::uniform   [inline, static]
 

Get a double-precision number from a uniformly distributed source of pseudo-random numbers.

Returns:
a pseudo-random number in the range [0,1]


The documentation for this class was generated from the following files:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.