Using the Random class to get independent random streams

Anything that doesn't fit elsewhere.
Post Reply
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Using the Random class to get independent random streams

Post by ted »

On 1/21/2005 a NEURON user wrote:
> I would like to use a "Point Process" mechanism for noise generation. I
> wrote one which seemed to work corectly, until I wanted to have
> uncorrelated noise on 2 cells. I got the same "NONSPECIFIC CURRENT" for
> each cell although I set the random seed with the "set_seed(n)" command in
> the INITIAL block and the seed parameters are different in the two cases.
>
> I have only a hand-made solution: if I compile the proper numbers of noise
> mechanism, with different "POINT_PROCESS" and file name; and attach these
> different POINT_PROCESSes to the different cells.
>
> I hope there is a better way to solve the problem

With all mechanisms that use the random number generator built into
NMODL, calling seed() resets the number sequence for ALL instances
of ALL distributions. And all random numbers are generated with the
same linear congruential generator, or the MCell Ran4 generator,
depending on whether use_mcell_ran4() has been called with an
argument of 0 or 1.

The Random class, with its play() method, is the only way to get
independent streams of numbers, so that each stream can have its
own seed and be at its own point in the numeric sequence. If you
use the Random class's play() method, each stream can use either
the MCell Ran4 generator, ACG (an "additive congruential generator"),
or MCG (a "multiplicative linear congruential generator"), independent
of what any other stream is using.

The Programmer's Reference describes the Random class and shows
an example of how to use its play() method to control the current
delivered by an IClamp. If you are using MSWin, you already have
a copy of the Programmer's Reference on your PC (look for the item
called Documentation in the NEURON Program Group). If you're using
OS X or UNIX/Linux, see the link at
http://www.neuron.yale.edu/neuron/docs
Post Reply