## Random noise

NMODL and the Channel Builder.
patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

### Random noise

Hi, I'm trying to study the effect of different kinds of noise in a simple one-compartment model, and I'm having some problems:
After succesfully playing with a simple white noise, now I want to model an Ornstein-Uhlenbeck process, which in the practice is a low-pass filtered white noise (isn't it?). The idea is to have a variable n defined by:

Code: Select all

``dn=(-n+µ)*dt/tc+s*dWt``
Where tc is a time constant, µ is the mean, dWt is the Wiener process and s is a parameter for the 'noise intensity' (so to speak).
Assuming µ=0 and s=1/tc, this can be written as

Code: Select all

``dn/dt=(-n+zt)/tc``
where zt is a normal random variable with mean=0 and some variance. n is then just added to the total current.
I put that into a .mod file that looks like

Code: Select all

``````TITLE Ornstein-Uhlenbeck process
NEURON {
SUFFIX OU
RANGE i, D, tau, bias
NONSPECIFIC_CURRENT i
}
UNITS { (mA) = (milliamp) }
PARAMETER {
bias = 0 (mA/cm2)
D = 0	(/ms)
tau = 1 	(ms)
}

ASSIGNED {
i (mA/cm2)
noise (mA/cm2)
}

STATE { n (mA/cm2) }

BREAKPOINT {
SOLVE kin
i = bias + n
}
DERIVATIVE kin {
noise = 1(mA/cm2) * normrand(0,D)
n' = (-n + noise)/tau
}``````
and it mainly works! But I am having two issues with it:
a) it only works with variable time step; under constant time step I always get a "division by zero" error or a "machine round-off" error.
b) sometimes, when running a long simulation (500-1000 seconds) the program exits without any warning or message. The only thing left is a nrniv.exe.stackdump file. This tends to happen more often when D>0.01, which actually doesn't cause too much noise in the voltage trace. Besides, the simulation can proceed without problem for 200+ seconds (yes, 2e5 ms) and then exit without any warning.
What can be possibly wrong with that? I'll appreciate any kind of comments regarding my approach.
By the way, I'm using Windows XP in a Pentium4 machine.

Regards.

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

### Re: Random noise

The SOLVE statement should specify an integration method. See
Integration methods for SOLVE statements
viewtopic.php?f=28&t=592
in the Hot tips section of the forum
viewforum.php?f=28

Try cnexp.

A comment: This mechanism should be used only with fixed time step integration. It does not seem like a good idea to use this mechanism with variable time step integration, because interactions between the effect of the noise source and the integrator's choice of time step and order of accuracy will corrupt the statistical properties of the noise source and confound the interpretation of results.

patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

### Re: Random noise

OK, thanks for the tip. Now it works with fixed timestep.
Two more questions:
1) Suddenly I realized that the correct way to go should be something like

Code: Select all

``````    noise = 1(mA/cm2) * normrand(0,D*sqrt(dt))
n' = (-n + noise)/tau
``````
i.e., correcting the variance by the dt. Would that make it more appropriate for a variable timestep method?

2) What happens when I don't specify the integration method? What does Neuron do (or try to do) in that case?

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

### Re: Random noise

patoorio wrote:correcting the variance by the dt. Would that make it more appropriate for a variable timestep method?
Has nothing to do with it. There are at least two classes of problems.

1. NEURON's adaptive integration methods use both variable order and variable time step. Variable time step forces repick from the random distribution at changing intervals. This changes the spectral content of the noise in unpredictable ways during the course of simulation. Very bad.

2. Reproducibility is adversely affected. Change any parameter of your model, and you also change the noise source. Why? Because a parameter change will make the adaptive integration choose a different sequence of time steps, and this in turn will change the times at which the noise currents are delivered.
What happens when I don't specify the integration method? What does Neuron do (or try to do) in that case?
SOLVE foo
will call foo at every fadvance(). foo should be defined as a PROCEDURE block, not a KINETIC or DERIVATIVE block. You will see this occasionally in old NMODL files for HH-style voltage-gated currents that exploit the analytical solution to the gating variables, an approach that works only with fixed time step integration. This has been superceded by
SOLVE foo METHOD cnexp
where foo is a DERIVATIVE block that contains the ODEs that govern the gating variables; this approach works with fixed and variable time step integration.

patoorio
Posts: 81
Joined: Wed Jan 30, 2008 12:46 pm

Clear as water.
Thanks a lot.