braintools.input.wiener_process

Contents

braintools.input.wiener_process#

braintools.input.wiener_process(duration, sigma=1.0, n=1, t_start=None, t_end=None, seed=None)#

Generate Wiener-process increments (Gaussian white noise).

Returns the per-step increments \(dW\) of a scaled Wiener process,

\[dW \sim \mathcal{N}(0, \sigma^2\, dt),\]

drawn independently at every time step. The result is white noise, not the cumulative Brownian path \(W(t)\); take cumsum along the time axis if you need the path.

dt enters as the numeric value of brainstate.environ.get_dt() in the unit it was set with, so sigma has units of current per square root of that time unit. The library does not convert time units here: use one consistent time unit for dt (and any other time constants) when choosing sigma. The same physical step written as 0.1 * u.ms or 1e-4 * u.second therefore gives increments of different size.

Parameters:
  • duration (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Total duration of the input signal. Supports time units.

  • sigma (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Noise intensity. Each increment has standard deviation sigma * sqrt(dt) with dt in its own unit. Supports current units. Default is 1.0.

  • n (int) – Number of independent Wiener processes to generate. Default is 1.

  • t_start (Array | ndarray | bool | number | bool | int | float | complex | Quantity | None) – Start time of the process. Before this, output is 0. Default is 0.

  • t_end (Array | ndarray | bool | number | bool | int | float | complex | Quantity | None) – End time of the process. After this, output is 0. Default is duration.

  • seed (int | None) – Random seed for reproducibility. Default is None (uses global random state).

Returns:

current – The increments dW. Shape is (n_timesteps,) if n=1, or (n_timesteps, n) if n>1.

Return type:

ndarray or Quantity

Examples

>>> import brainunit as u
>>> import brainstate
>>> from braintools.input import wiener_process
>>> brainstate.environ.set(dt=0.1 * u.ms)

Simple Wiener process

>>> noise = wiener_process(
...     duration=100 * u.ms,
...     sigma=0.5 * u.pA
... )

Multiple independent processes

>>> noises = wiener_process(
...     duration=200 * u.ms,
...     sigma=1.0 * u.nA,
...     n=10  # 10 independent processes
... )

Windowed noise

>>> noise = wiener_process(
...     duration=500 * u.ms,
...     sigma=2.0 * u.pA,
...     t_start=100 * u.ms,
...     t_end=400 * u.ms
... )

Reproducible noise

>>> noise = wiener_process(
...     duration=100 * u.ms,
...     sigma=0.3 * u.nA,
...     seed=42  # Fixed seed for reproducibility
... )

Notes

  • Each sample is an increment: Var(dW) = σ²·dt, E[dW] = 0.

  • Increments are independent, so the output is white noise; the Brownian path is cumsum(dW).