yat  0.10.4pre
Public Types | Public Member Functions | Protected Attributes
theplu::yat::random::DiscreteUniform Class Reference

Discrete uniform distribution. More...

#include </scratch/bob/jari/tmp/pristine/yat-0.10.x/yat/random/random.h>

Inheritance diagram for theplu::yat::random::DiscreteUniform:
theplu::yat::random::Discrete

List of all members.

Public Types

typedef unsigned long int result_type

Public Member Functions

 DiscreteUniform (unsigned long n=0)
 Constructor.
unsigned long operator() (void) const
 Get a random number.
unsigned long operator() (unsigned long n) const
 Get a random integer in the range $ [0,n-1] $.
void seed (unsigned long s) const
 Set the seed to s.
unsigned long seed_from_devurandom (void)
 Set the seed using the /dev/urandom device.

Protected Attributes

RNGrng_
 GSL random gererator.

Detailed Description

Discrete uniform distribution.

Discrete uniform distribution also known as the "equally likely outcomes" distribution. Each outcome, in this case an integer from [0,n-1] , have equal probability to occur.

Distribution function $ p(k) = \frac{1}{n+1} $ for $ 0 \le k < n $
Expectation value: $ \frac{n-1}{2} $
Variance: $ \frac{1}{12}(n-1)(n+1) $


Member Typedef Documentation

typedef unsigned long int theplu::yat::random::Discrete::result_type
inherited

type returned by operator()

Since:
New in yat 0.10

Constructor & Destructor Documentation

theplu::yat::random::DiscreteUniform::DiscreteUniform ( unsigned long  n = 0)
explicit

Constructor.

The generator will generate integers within the range $ [0,n-1] $. If n is zero, then the whole range of the underlying RNG will be used $ [min,max] $. Setting n to zero is the preferred way to sample the whole range of the underlying RNG, i.e. not setting
to RNG.max.

Exceptions:
Ifn is larger than the maximum number the underlying random number generator can return, then a GSL_error exception is thrown.

Member Function Documentation

unsigned long theplu::yat::random::DiscreteUniform::operator() ( void  ) const
virtual

Get a random number.

The returned integer is either in the range [RNG.min,RNG.max] or [0,n-1] depending on how the random number generator was created.

See also:
DiscreteUniform(const unsigned long n=0)

Implements theplu::yat::random::Discrete.

unsigned long theplu::yat::random::DiscreteUniform::operator() ( unsigned long  n) const

Get a random integer in the range $ [0,n-1] $.

All integers in the range [0,n-1] are equally likely. This function should be avoided for sampling the whole range of the underlying RNG.

Exceptions:
GSL_errorif n is larger than the range of the underlying generator.
void theplu::yat::random::Discrete::seed ( unsigned long  s) const
inherited

Set the seed to s.

Set the seed to s in the underlying rng. If s is zero, a default value from the rng's original implementation is used (cf. GSL documentation).

Deprecated:
Provided for backward compatibility with the 0.7 API. Use RNG::instance()->seed(s) instead.
unsigned long theplu::yat::random::Discrete::seed_from_devurandom ( void  )
inherited

Set the seed using the /dev/urandom device.

Returns:
The seed acquired from /dev/urandom.
Deprecated:
Provided for backward compatibility with the 0.7 API. Use RNG::instance()->seed_from_devurandom() instead.

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

Generated on Mon Nov 11 2013 09:41:45 for yat by  doxygen 1.8.1