NetStim Event Times Same from Trial to Trial?
NetStim Event Times Same from Trial to Trial?
Hi, I am using NetStim to generate poisson-distributed event times to drive synapses. To my surprise, everytime I run the simulation the NetStim events seem to be occurring at the same time. I would have thought that the poisson-distributed event times would be generated probabilistically every time the simulation is run and thus would be different on a trial-to-trial basis. Is there a way to make the event times differ trial to trial?
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: NetStim Event Times Same from Trial to Trial?
That would be a bug, not a feature (indeed, when it happens it is usually a symptom of an initialization error in a mod file). It would destroy your ability to write reproducible, debuggable code. Given input I, program P should always produce the same output O regardless of how many times P has been run.Yaeger wrote:I would have thought that the poisson-distributed event times would be generated probabilistically every time the simulation is run and thus would be different on a trial-to-trial basis.
What you need to do is change the "program's input" from one run to the next. The way to do that is by changing the seed(s) used by the random number generator(s). You want to do that in such a way that the pseudorandom sequences generated during one run are statistically independent of the sequences that are generated in the next run. Random123 is an excellent generator for this task--read about it in the Programmer's Reference
http://www.neuron.yale.edu/neuron/stati ... .Random123
For the sake of reproducibility, it is absolutely essential to keep track of the seeds that were (or are to be*) used in each run.
*--One common practice is to generate, in advance, a file that contains a list of seeds that will be used, before executing a sequence of "production runs" that draws on those seeds.
Re: NetStim Event Times Same from Trial to Trial?
Hi Ted -
Thanks for the quick and helpful reply. Sorry it has taken me a bit to reply. Per your advice I have generated some code to create a vector of random numbers using Random123.
Then I have a file that generates events at different frequencies and uses one of the random seeds contained in the vector rvec in the above code as the random seed for the NetStim i.e.:
What I am wondering (due to my ignorance of random number generators) is whether there is any interaction between the specific random seed used and the negative exponential distribution generated by "ns.noise = 1" at different NetStim interval values ? Is it appropriate to use the same random seed regardless of the NetStim interval size?
Thanks for the quick and helpful reply. Sorry it has taken me a bit to reply. Per your advice I have generated some code to create a vector of random numbers using Random123.
Code: Select all
objref r
r = new Random()
r.negexp(1)
r.Random123(1)
objref rvec
rvec = new Vector()
proc genran() { local i, seed
for i = 1,$1 {
myseed = r.repick
rvec.append(myseed)
}
}
genran(10)
Code: Select all
proc batrun() { local i, isi
for i = 1,$1 {
isi = 1000/(310 - i)
useseed = rvec.x[0]
ns.seed(useseed)
ns.interval = isi
ns.noise = 1
run()
}
}
What I am wondering (due to my ignorance of random number generators) is whether there is any interaction between the specific random seed used and the negative exponential distribution generated by "ns.noise = 1" at different NetStim interval values ? Is it appropriate to use the same random seed regardless of the NetStim interval size?
Re: NetStim Event Times Same from Trial to Trial?
Now I am seeing that there is a problem with this code, although I am not sure where it is. For random seeds between zero and one, the NetStim generates the same interevent intervals.
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: NetStim Event Times Same from Trial to Trial?
Before carrying on further, it would be good to read the documentation on Randomness in NEURON models. See the link with that name on NEURON's Documentation page http://www.neuron.yale.edu/neuron/docs. Although the example provided uses MCellRan4, after you have worked through the code it shouldn't be too hard for you modify it so that it uses Random123. Then you'll be in a much better position to pick up with your own project.