I want to add Gaussian white noise to the membrane voltage of a Hodgkin-Huxley neuron like this: dv/dt = .... +sigma*xi*(2*gl/Cm)**.5
Where sigma is 6.5*mV. This works with LIF neurons and ‘euler’ integration method but not with HH neurons and ‘exponential-euler’ integration method. I get the error: brian2.stateupdaters.base.UnsupportedEquationsException: Cannot solve stochastic equations with this state updater.

Is there another way to implement this exact type of noise? I’ve attempted with the PoissonInput class but can’t seem to get it the same.

Hi. As soon as you add noise to your equations, the equation becomes a stochastic differential equation (SDE) and the numerical integration method has to take care of this. The Euler method has built-in support for this type of randomness, and the “milstein” and “heun” methods support even more complex noise terms. The exponential Euler method does not support it at the moment (same for RK2, RK4, …), even though I think there are extensions of this method to SDEs.

To solve this issue with the current version of Brian, you have two options:

Use a solver like “milstein” or “heun” that can deal with the noise term – but note that they might have numerical stability issues with the HH equations.

Calculate an approximation of the noise yourself instead of including the “ideal noise” term in the equations.

For 2, you can use the approximation that is used by the Euler algorithm, i.e. an appropriately scaled normal random number that is constant over the time step. To do this in your equations, replace sigma*xi*(2*gl/Cm)**.5 by noise, and add the following definition to your equations:

'''...
noise = sigma*xi*(2*gl/Cm)**.5*randn()/sqrt(dt) : 1/second (constant over dt)
'''