Add Ornstein–Uhlenbeck noise generator
Add Ornstein–Uhlenbeck Noise Generator
This pull request adds a new ou_noise_generator device and corresponding pytest-based tests. The device generates temporally correlated current following an Ornstein–Uhlenbeck (OU). The tests verify both parameter handling and statistical properties.
Model Implementation
-
Files added
-
models/ou_noise_generator.h -
models/ou_noise_generator.cpp -
pytests/sli2py_stimulating/test_ou_noise_generator.py
-
-
Process equation The state variable (x) evolves as
$$ dx = \frac{1}{\tau}(\mu - x)\ dt + \sigma\ dW $$
where
-
($\mu$) (
meanparameter) is the long-term mean of the process, -
($\sigma$) (
stdparameter) its stationary standard deviation, -
($\tau$) (
tauparameter) is the time constant, -
dtis the internal integration step. -
Integration and output
- Internally integrates the OU equation at user-specified
dt. - On each simulation step it emits the current (x) to connected targets.
- Internally integrates the OU equation at user-specified
Tests (test_ou_noise_generator.py)
-
Parameter setting and defaults
- Verifies that
set()andSetDefaults()both correctly configure all parameters (mean,std,tau,dt).
- Verifies that
-
Error conditions
- Asserts that attempting to create the generator with a
dtnot divisible bynest.resolutionraisesStepMultipleRequired.
- Asserts that attempting to create the generator with a
-
Mean and variance
- Runs 100 trials of 1000 ms each, records the last current value, and checks that the sample mean and variance match the target $\mu$ and $\sigma^2$ within reasonable statistical bounds.
-
Autocorrelation
- Collects a long trace, discards the initial $10\tau$ burn-in, and computes the empirical lag-1 autocorrelation.
- Confirms it matches $\exp(-\text{dt}/\tau)$ within a small tolerance.
-
Cross-correlation
- Connects a single OU generator to two independent neurons and records their membrane potentials.
- Computes the cross-correlation of the two voltage traces and verifies it remains near zero.
@FinnBurkhardt Would you be able to address the open issues within a few days? I also added two minor suggestions. Please merge master into your branch for this PR to ensure that the testsuite works properly.
Thanks for the contribution! I have a minor change for the docs, and a question if there is a good use case we can use an example for this generator?
Thanks, I’ve applied the suggested changes.
For examples, I’d have two candidates at hand:
-
Single neuron driven by the OU noise generator.
-
White vs. OU noise (matched mean/variance), comparing firing rate and coefficient of variation.
Would one (or both) be useful for the docs?
@FinnBurkhardt if they are ready then we could take both. You can add them to pynest/examples/ (please adhere to the style of docstring as in the other examples)
And you can add it to the doc/htmldoc/examples/index.rst page: I think in the 'stimulating network' section would make sense?
.. grid-item-card:: Stimulating networks
:img-top: ../static/img/pynest/sensitivitypertubation.png
* :doc:`../auto_examples/sinusoidal_poisson_generator`
* :doc:`../auto_examples/sinusoidal_gamma_generator`
* :doc:`../auto_examples/repeated_stimulation`
* :doc:`../auto_examples/sensitivity_to_perturbation`
* :doc:`../auto_examples/intrinsic_currents_spiking`
* :doc:`../auto_examples/intrinsic_currents_subthreshold`
It also needs to be added to the .. toctree::
I can also help with this if it's confusing!