# How to get stochasticity in LIF neurons?

Hello,

1. What is the right way to get stochasticity in LIF neurons? Is it already implemented in nengo or one must create a new neuron type in nengo?
2. How is the noise (from the noise parameter in Ensemble) injected in LIF neurons?
3. Where does noise happen in the Nengo simulator and how is it taken into account?

I want stochasticity in LIF neurons. I have read online that to get stochastic neurons, one should implement the Ornstein-Uhlenbeck (O-U) process. After my research on the Nengo forum on how to introduce stochasticity, I came across White Noise processes and there was a reference in the docstring

References
----------
â€¦ [1] Gillespie, D.T. (1996) Exact numerical simulation of the Ornstein-
Uhlenbeck process and its integral. Phys. Rev. E 54, pp. 2084-91.

However, in step_whitenoise, I donâ€™t see any O-U process implementation. It is just a simple White noise implementation.

``````     def step_whitenoise(_):
x = dist.sample(n=1, d=shape_out[0], rng=rng)[0]
return alpha * x if scale else x
``````

So, I wondered why there is a reference to the O-U process in white noise. Is the O-U process implemented elsewhere?

I can see the stochasticity when I pass the white noise process as a noise parameter in the ensemble like this:

``````process = nengo.processes.WhiteNoise(dist=nengo.dists.Gaussian(0, 1), scale=True, seed=0)

ens_param = dict(n_neurons=n_in_neurons,
dimensions=1,
seed=0,
intercepts=np.ones(shape=(n_in_neurons,)) * 0.5,
)
ens_1 = nengo.Ensemble(noise=process,
label="ens with noise",
**ens_param)
``````

Is the right way to introduce stochasticity in LIF neurons?

At what stage of nengo implementation (run, build, sim, etc) is the noise injected in LIF neurons? Where exactly does it happen? Can you please point me to the source code?

The O-U process is implemented as `FilteredNoise`.
Thatâ€™s the correct way to add noise to an ensemble. Itâ€™s implemented here, where the output of the noise process is set to be added to (`mode="inc"`) the neuronsâ€™ input currents. That `build` call will then call the `Process` builder.