You should modify your noise current source mod file to use the same code pattern for randomness that is implemented in the nrn/src/nrnoc/netstim.mod file.
The relevant fragment, which you can put at the end of your mod file, is
Code: Select all
NEURON { POINTER donotuse THREADSAFE} : to hold a reference to a Hoc Random instance.
ASSIGNED{ donotuse }
VERBATIM
double nrn_random_pick(void* r);
void* nrn_random_arg(int argpos);
ENDVERBATIM
FUNCTION myrand() {
VERBATIM
if (_p_donotuse) {
_lmyrand = nrn_random_pick(_p_donotuse);
}else{
/* only can be used in main thread */
if (_nt != nrn_threads) {
hoc_execerror("multithread random in NetStim"," only via hoc Random");
}
ENDVERBATIM
:your old random stuff goes here which is used if you are not useing hoc Random
erand = ....
VERBATIM
}
ENDVERBATIM
}
PROCEDURE noiseFromRandom() {
VERBATIM
{
void** pv = (void**)(&_p_donotuse);
if (ifarg(1)) {
*pv = nrn_random_arg(1);
}else{
*pv = (void*)0;
}
}
ENDVERBATIM
}
Then in hoc, if your POINT_PROCESS is called Foo, you would attach an instance of Random to an instance of foo as in
objref foo, ran
foo = new Foo(.5)
ran = new Random()
foo.noise_from_random(ran)
and then set the proper distribution for ran ( ran.norm(...)?)
and now for statistically independent, reproducible random streams use
ran.MCellRan4(...) or ran.Random123(id1, id2).
http://www.neuron.yale.edu/neuron/stati ... #MCellRan4
http://www.neuron.yale.edu/neuron/stati ... #Random123
The latter is new in 7.3 but I highly recommend trying it out. id1 and id2 give you tremendous flexibility ind
defining your independent reproducible, streams. Another integer (ran.Random123_globalindex(id3)) means that if you run
n simulations with
for id3=0, n { anyraninstance.Random123_globalindex(id3) run() } then all streams of all runs will be statistically independent.
Finally there is an internal id4 (all the id0,1,2,3 range from 0 to 2^32-1) which is the sequence index of the stream.
You can see that this is administratively simpler than MCellRan4 where all aspects including sequence have to be mapped into
just two integers.
By the way. Whatever you end up with, be sure to test with printf statements so there are no surprises on your part about what is
going on.
I generally don't like picking a random number per time step unless you have carefully considered the effect of the dt dependence of the
noise frequency spectrum. The extreme case is that for constant parameters of the distribution, noisiness eventually disappears as dt -> 0.
ie. I faintly recall that noise parameters have to be related to the square root of dt. Perhapse someone could weigh in on this.
It would seem that one would want the noise spectrum to be independent of dt. I wonder if one should only pick at fixed Dt intervals
as one decreases dt.