# Description of problem

I added the xi variable to my neuron equation to generate noisy membrane potentials.
I would like to record the xi values as a function of time and plot it in a graph, but I failed.

If xi is not recordable, is there any other way to add a noisy current to a neuron and record the noise term?

# Minimal code to reproduce problem

``````eqs = '''
dv/dt = (Iint-(v-v0))/tau + sigma*xi*tau**-0.5: 1 (unless refractory)
ref: second
'''
G = NeuronGroup(Nneuron, eqs, threshold='v > v_threshold', reset='v = v_reset', refractory='ref', method='Euler')
M = StateMonitor(G, ('v', 'xi'), record=True)  # record the membrane potential
run(1000*ms)
plot(M.t/ms, M.xi[0], color='black')
show()
``````

# Expected output (if relevant)

A plot with a Gaussian distributed noise as a function of time

# Actual output (if relevant)

A flat line of y=0

Hi @cclo. I agree that this is not ideal – in particular, you should get an error message when trying to record from `xi`. The reason why this isn’t possible is that internally, there is no variable named `xi`, it is directly taken in charge as part of the numerical integration process. As an alternative, you can replace it by a variable that does the same thing manually, and which you can then record in the usual way:

``````eqs = '''
dv/dt = sigma*noise*tau**-0.5: 1 (unless refractory)
noise = randn()/sqrt(dt) : second**-0.5 (constant over dt)
...
'''
``````

The value of `noise` might still not quite what you expect, since the values will depend on the `dt` that is used for the simulation. This is correct, though (see Models and neuron groups — Brian 2 2.6.0 documentation for a short explication). If you are only interested in the values of the random generator you could of course reformulate everything as, for example:

``````eqs = '''
dv/dt = sigma*noise/sqrt(dt)*tau**-0.5: 1 (unless refractory)
noise = randn() : 1 (constant over dt)
...
'''
``````