NEST  2.6.0,not_revisioned_source_dir@0
Modules
Random Number and Deviate Generation in NEST.

This module contains the interface to random numbers and random deviate generators. More...

Modules

 Random Deviate Generators.
 Random deviate generators (RDGs) produce random numbers with various distributions on the basis of [0,1) uniformly distributed numbers.
 
 Uniform Random Number Generators.
 All generators are derived from base class RandomGen.
 

Detailed Description

This module contains the interface to random numbers and random deviate generators.

We differentiate between

random number generators: generate uniformly distributed numbers.

random deviate generators: generate non-uniformly distributed numbers, eg, Poisson, binomial or gamma distributed numbers.

Note
In the NEST kernel, random number generators are managed by the scheduler on a thread-by-thread basis. Nodes requiring random numbers must access random numbers and deviates only through the interface provided by the scheduler, as in the follwing example taken from nest::poisson_generator.
class poisson_generator :
public Node,
protected Device
{
...
private:
...
};
:...
poisson_dev_(0.0),
...
{
calibrate(network()->get_resolution());
}
{
poisson_dev_.set_lambda(dt.get_ms() * rate_*1e-3);
}
void nest::poisson_generator::update(thread thrd, Time const & T)
{
...
...
long_t n_spikes = poisson_dev_.ldev(rng);
...
}

Note that the RNG used by the deviate generator must be obtained via get_rng(thrd) on each call to update, to get the proper generator for the present thread.

If one wanted just uniformly distributed numbers in [0, 1), one could obtain them with

librandom::RngPtr rng=Node::network()->get_rng(thrd);
double r = rng();
Note
Random number generators should be managed through safe RngPtr pointers, not through plain RandomGen*.
All elements are in namespace librandom.