Additive noise implementation

pietro
Tue, 19 Mar 2024 13:14:10 +0000
Support

Description of problem

Hello everyone, I’m trying to implement a model featuring additive noise, intended to be a zero-mean unit-variance normal random variable multiplied by a parameter of the model, sigma. I’m having trouble implementing a noise source capable of having the same variance independently of integration step.

Minimal code to reproduce problem

import brian2 as br
from scipy.stats import norm
dt = 0.1
T = 10
sigma = 1
br.start_scope()
br.defaultclock.dt = dt * br.ms
duration = T * br.ms
eqs='''
dphi/dt = sigma_int * xi : 1
sigma_int : hertz ** 0.5
'''
neurons = br.NeuronGroup(100,eqs,method='heun')
neurons.sigma_int = sigma * br.Hz ** 0.5
noise = br.StateMonitor(neurons,'phi',record=True)
br.run(duration)

What you have aready tried

I first tried to record the values of xi using a brian monitor in order to check its variance and see whether it depended on dt, but failed to implement the monitor without errors. I then resorted to computing noise variance using the following code (unsure of its correctness though):

noise = (noise.phi[:,1:]-noise.phi[:,:-1]) / dt
mu, std = norm.fit(np.ndarray.flatten(noise))

Expected output

I was expecting std to be 1 independently of dt, since I kept sigma fixed to 1 for now

Actual output

std varied from 0.2 to 1 changing dt (with values between 0.01 and 5)

4 posts - 2 participants