Skip to content

Add Ornstein–Uhlenbeck noise generator #3541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

FinnBurkhardt
Copy link

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$) (mean parameter) is the long-term mean of the process,

  • ($\sigma$) (std parameter) its stationary standard deviation,

  • ($\tau$) (tau parameter) is the time constant,

  • dt is 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.

Tests (test_ou_noise_generator.py)

  • Parameter setting and defaults

    • Verifies that set() and SetDefaults() both correctly configure all parameters (mean, std, tau, dt).
  • Error conditions

    • Asserts that attempting to create the generator with a dt not divisible by nest.resolution raises StepMultipleRequired.
  • 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.

@heplesser heplesser added T: Enhancement New functionality, model or documentation S: Normal Handle this with default priority I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Aug 7, 2025
@heplesser heplesser added this to Models Aug 7, 2025
@github-project-automation github-project-automation bot moved this to To do in Models Aug 7, 2025
@jessica-mitchell jessica-mitchell changed the title Add ou generator Add Ornstein–Uhlenbeck noise generator Aug 11, 2025
Copy link
Contributor

@jessica-mitchell jessica-mitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

.. admonition:: Recording the generated current

You can use a :doc:`multimeter <multimeter>` to record the average current sent to all targets for each time step if
simulating on a single thread; multiple MPI processes with one thread each also work. In this case, the recording
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
simulating on a single thread; multiple MPI processes with one thread each also work. In this case, the recording
simulating on a single thread; multiple MPI processes with one thread each also work. In this case, the recording


You can use a :doc:`multimeter <multimeter>` to record the average current sent to all targets for each time step if
simulating on a single thread; multiple MPI processes with one thread each also work. In this case, the recording
interval of the multimeter should be equal to the `dt` of the generator to avoid aliasing effects. In multi-threaded
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
interval of the multimeter should be equal to the `dt` of the generator to avoid aliasing effects. In multi-threaded
interval of the multimeter should be equal to the `dt` of the generator to avoid aliasing effects. In multi-threaded

You can use a :doc:`multimeter <multimeter>` to record the average current sent to all targets for each time step if
simulating on a single thread; multiple MPI processes with one thread each also work. In this case, the recording
interval of the multimeter should be equal to the `dt` of the generator to avoid aliasing effects. In multi-threaded
mode, recording of noise currents is prohibited for technical reasons.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mode, recording of noise currents is prohibited for technical reasons.
mode, recording of noise currents is prohibited for technical reasons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire paragraph needs to be indented to be included in the admonition

@github-project-automation github-project-automation bot moved this from To do to Review in Models Aug 11, 2025
@terhorstd terhorstd requested a review from jakobkramp August 13, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Enhancement New functionality, model or documentation
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

4 participants