class Random

Random class which contains several static random methods.

Public Methods

[more]static void seed()
Initializes the random number generator with the computer clock
[more]static void manualSeed(unsigned long the_seed_)
Initializes the random number generator with the given long "the_seed_"
[more]static unsigned long getInitialSeed()
Returns the starting seed used
[more]static unsigned long random()
Generates a uniform 32 bits integer
[more]static real uniform()
Generates a uniform random number on [0,1[
[more]static void getShuffledIndices(int* indices, int n_indices)
Returns in indices n_indices shuffled.
[more]static void shuffle(void* tabular, int size_elem, int n_elems)
Shuffles tabular, which contains n_elems of size size_elem
[more]static real boundedUniform(real a, real b)
Generates a uniform random number on [a,b[ (b>a)
[more]static real normal(real mean=0, real stdv=1)
Generates a random number from a normal distribution.
[more]static real exponential(real lambda)
Generates a random number from an exponential distribution.
[more]static real cauchy(real median=0, real sigma=1)
Returns a random number from a Cauchy distribution.
[more]static real logNormal(real mean, real stdv)
Generates a random number from a log-normal distribution.
[more]static int geometric(real p)
Generates a random number from a geometric distribution.
[more]static bool bernouilli(real p=0.5)
Returns true with probability and false with probability (p > 0)


Documentation

Random class which contains several static random methods.

These methods are based on a uniform random generator, named "Mersenne Twister", available at: http://www.math.keio.ac.jp/matumoto/emt.html. Copyright Makoto Matsumoto and Takuji Nishimura. (Have a look inside the implementation file for details).

The random generator can be initialized with the manualSeed() method. Otherwise, it will be automatically initialized with a seed based on the current computer clock.

ostatic void seed()
Initializes the random number generator with the computer clock

ostatic void manualSeed(unsigned long the_seed_)
Initializes the random number generator with the given long "the_seed_"

ostatic unsigned long getInitialSeed()
Returns the starting seed used

ostatic unsigned long random()
Generates a uniform 32 bits integer

ostatic real uniform()
Generates a uniform random number on [0,1[

ostatic void getShuffledIndices(int* indices, int n_indices)
Returns in indices n_indices shuffled. (between 0 and n_indices-1).

ostatic void shuffle(void* tabular, int size_elem, int n_elems)
Shuffles tabular, which contains n_elems of size size_elem

ostatic real boundedUniform(real a, real b)
Generates a uniform random number on [a,b[ (b>a)

ostatic real normal(real mean=0, real stdv=1)
Generates a random number from a normal distribution. (With mean mean and standard deviation stdv >= 0).

ostatic real exponential(real lambda)
Generates a random number from an exponential distribution. The density is , where lambda is a positive number.

ostatic real cauchy(real median=0, real sigma=1)
Returns a random number from a Cauchy distribution. The Cauchy density is

ostatic real logNormal(real mean, real stdv)
Generates a random number from a log-normal distribution. (mean > 0 is the mean of the log-normal distribution and stdv is its standard deviation).

ostatic int geometric(real p)
Generates a random number from a geometric distribution. It returns an integer i, where . p must satisfy .

ostatic bool bernouilli(real p=0.5)
Returns true with probability and false with probability (p > 0)


This class has no child classes.
Author:
Ronan Collobert (collober@idiap.ch)

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.