yat
0.20.3pre
|
Discrete uniform distribution. More...
#include <yat/random/random.h>
Public Types | |
typedef unsigned long | argument_type |
argument type is unsigned long int | |
typedef unsigned long int | result_type |
Public Member Functions | |
DiscreteUniform (unsigned long n=0) | |
Constructor. More... | |
unsigned long | operator() (void) const |
Get a random number. More... | |
unsigned long | operator() (unsigned long n) const |
Get a random integer in the range . More... | |
unsigned long int | min (void) const |
unsigned long int | max (void) const |
void | seed (unsigned long s) const |
Set the seed to s. More... | |
unsigned long | seed_from_devurandom (void) |
Set the seed using the /dev/urandom device. More... | |
Protected Attributes | |
RNG * | rng_ |
GSL random gererator. | |
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 for
Expectation value:
Variance:
|
inherited |
type returned by operator()
|
explicit |
Constructor.
The generator will generate integers within the range . If n is zero, then the whole range of the underlying RNG will be used . Setting n to zero is the preferred way to sample the whole range of the underlying RNG, i.e. not setting
to RNG.max.
If | n is larger than the maximum number the underlying random number generator can return, then a GSL_error exception is thrown. |
unsigned long int theplu::yat::random::DiscreteUniform::max | ( | void | ) | const |
For n>0 the max value is n-1. For n=0 (default) the max value is RNG::max().
unsigned long int theplu::yat::random::DiscreteUniform::min | ( | void | ) | const |
For n>0 the min value is 0. For n=0 (default) the min value is RNG::min(), typically zero but depending on generator in use.
|
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.
Implements theplu::yat::random::Discrete.
unsigned long theplu::yat::random::DiscreteUniform::operator() | ( | unsigned long | n | ) | const |
Get a random integer in the range .
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.
GSL_error | if n is larger than the range of the underlying generator. |
|
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).
|
inherited |
Set the seed using the /dev/urandom device.