Is one set_seed enough?

Anything that doesn't fit elsewhere.
Post Reply
pfortier
Posts: 47
Joined: Thu Apr 20, 2006 8:02 am
Location: University of Ottawa

Is one set_seed enough?

Post by pfortier » Sat Mar 28, 2009 5:11 pm

I have 5 neurons each with 3 different mechanisms (3 different mod files). Each mod file has a procedure to execute "set_seed(seed)" where argument seed is provided by the hoc file. So set_seed() is called with 5*3=15 different seed values.

The mod files use either normrand() or scop_random() to get random numbers. All I want to ensure is that the 15 instances generate different sequences of random numbers.

Setting 5*3=15 different seed values is appropriate if there are 15 seperate random number generators (one for each instance). But if there is only 1 random number generator for each simulation then I only need to call it once.

How many random number generators would there be in the setup described in the first paragraph?

Thanks,
Pierre

ted
Site Admin
Posts: 5689
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Is one set_seed enough?

Post by ted » Sun Mar 29, 2009 11:08 am

Should be straightforward to discover for yourself.
Revise the mechanisms so that the variable that is assigned a pseudorandom value is RANGE.
Make a toy model with just one cell.
Use Vector record() to capture the time course of those variables.

Test 1:
Call only one mechanism's set_seed to initialize the seed to some value A
mech1.set_seed(A)
Run a simulation just long enough to generate ~5 pseudorandom values in each recorded Vector.
Copy the recorded Vectors to a new set of vectors.

Compare the copies of the recorded vectors to each other. If the mechanisms are taking turns drawing values from a single pseudorandom sequence, the three vectors should have very different contents. If each mechanism has its own seed, the two mechanisms that you did not seed should produce vectors that contain identical values.

Test 2:
Call each mechanism's set_seed, but use different values B and C for mechanisms 2 and 3, and call mechanism 1's set_seed last, with the same seed as in the first run.
mech2.set_seed(B)
mech3.set_seed(C)
mech1.set_seed(A)

Compare the recorded vectors to each other. If the mechanisms are taking turns drawing values from a single pseudorandom sequence, the three vectors should have very different contents, and each vector should contain values that are identical to those values that it recorded in Test 1. If each mechanism has its own seed, mechanism 1's vector should be identical to what it was in Test 1. The vectors for mechanisms 2 and 3 should have different values from each other and from mechanism 1's vector.

What did you find out?

pfortier
Posts: 47
Joined: Thu Apr 20, 2006 8:02 am
Location: University of Ottawa

Re: Is one set_seed enough?

Post by pfortier » Thu Apr 02, 2009 6:21 pm

Just after pressing submit, I realised that I could have tested it myself. So I appreciate your response. The results of my tests are that there is only 1 random number generator so I only need to set_seed once. Hopefully, I did it right.

So this would be different from Random() since the manual states "Note that multiple instances of the Random class will produce different streams of random numbers only if their seeds are different."

Post Reply