AndroMeta  2.0.0
Public Member Functions
Meta::MRandom Class Reference

Random number generation and probability distributions. More...

#include <MRandom.h>

Inheritance diagram for Meta::MRandom:
Meta::MObject Meta::MProcessor Meta::MObjectBase

List of all members.

Public Member Functions

 MRandom (uint64_t seed=0)
 MRandom (const mvar &v, RestoreOpt opt)
 MRandom (const MRandom &random)
 ~MRandom ()
void store (mvar &v) const
MObjectclone () const
void setSeed (uint64_t seed)
uint64_t timeSeed ()
double uniform ()
double uniform (double a, double b)
double exponential (double x)
double normal (double m, double s)
double erlang (double n, double x)
double pareto (double k, double a)
double lognormal (double a, double b)
double chisquare (double n)
long bernoulli (double p)
long equilikely (long a, long b)
long binomial (long n, double p)
long geometric (double p)
long bpascal (long n, double p)
long poisson (double m)
mvec sequence (long a, long b)
virtual mnode process (mnode n, uint32_t flags=0)

Detailed Description

Random number generation and probability distributions.

Includes a number of discrete and continuous probability distributions. MRandom is storeable and restoreable.


Constructor & Destructor Documentation

Meta::MRandom::MRandom ( uint64_t  seed = 0)

Constructor.

Meta::MRandom::MRandom ( const mvar v,
RestoreOpt  opt 
)

Restore constructor.

Meta::MRandom::MRandom ( const MRandom random)

Copy constructor.

Destructor.


Member Function Documentation

long Meta::MRandom::bernoulli ( double  p)
Returns:
y, a random number from a bernoulli distribution such that y = 0 or 1 with mean = p and variance = p * (1 - p).
long Meta::MRandom::binomial ( long  n,
double  p 
)
Returns:
y, a random number from a binomial distribution with range 0..n with mean = n * p and variance = n * p * (1 - p).
long Meta::MRandom::bpascal ( long  n,
double  p 
)
Returns:
y, a random number from a pascal distribution with range 1..inf with mean = n / p and variance = n * (1 - p) / (p * p).
double Meta::MRandom::chisquare ( double  n)
Returns:
y, a random number from a chi-square distribution such that y > 0 with mean = n and variance = 2*n.
MObject* Meta::MRandom::clone ( ) const [virtual]

Copy this MRandom.

Reimplemented from Meta::MObject.

long Meta::MRandom::equilikely ( long  a,
long  b 
)
Returns:
y, a random number from an 'equilikely' distribution with range a..b with mean = (a + b) / 2 and variance = ((b - a + 1) * (b - a + 1) - 1)/12.
double Meta::MRandom::erlang ( double  n,
double  x 
)
Returns:
y, a random number from an erlang distribution such that y > 0 with mean = n*x and variance = n*x^2.
double Meta::MRandom::exponential ( double  x)
Returns:
y, a random number from an exponential distribution such that y > 0 with mean = 1/x and variance = 1/x^2.
long Meta::MRandom::geometric ( double  p)
Returns:
y, a random number from a geometric distribution with range 1..inf with mean = 1 / p and variance = (1 - p) / p^2.
double Meta::MRandom::lognormal ( double  a,
double  b 
)
Returns:
y, a random number from a lognormal distribution such that y > 0 with mean = exp(a + 0.5 * b^2) and variance = (exp(b^2) - 1) * exp(2 * a + b^2).
double Meta::MRandom::normal ( double  m,
double  s 
)
Returns:
y, a random number from a normal distribution such that -inf < y < inf with mean = m and variance = s^2.
double Meta::MRandom::pareto ( double  k,
double  a 
)
Returns:
y, a random number from a pareto distribution such that y >= k > 0 with mean = a * k / (a - 1) a > 1 and variance = a * k^2 / ((a - 1)^2 * (a - 2)) a > 2.
long Meta::MRandom::poisson ( double  m)
Returns:
y, a random number from a poisson distribution with range 0..inf with mean = m and variance = m.
virtual mnode Meta::MRandom::process ( mnode  n,
uint32_t  flags = 0 
) [virtual]

Process method.

Reimplemented from Meta::MObject.

mvec Meta::MRandom::sequence ( long  a,
long  b 
)
Returns:
A random integer sequence from the interval [a,b].
void Meta::MRandom::setSeed ( uint64_t  seed)

Reset the seed of the random number generator.

void Meta::MRandom::store ( mvar v) const [virtual]

Store the state of this MRandom to v.

Reimplemented from Meta::MObject.

Seed the random number generator with the current time.

Returns:
The seed used.
Returns:
y, a uniformly distributed number such that 0 < y < 1.
double Meta::MRandom::uniform ( double  a,
double  b 
)
Returns:
y, a uniformly distributed number such that a < y < b.

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