braintools.input.WienerProcess

braintools.input.WienerProcess#

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

Generate Wiener-process increments (Gaussian white noise).

Produces the per-step increments of a scaled Wiener process,

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

drawn independently at every time step. The output 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; the library does not convert time units. Use one consistent time unit for dt when choosing sigma (the same physical step written as 0.1 * u.ms or 1e-4 * u.second 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.

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

  • sigma (float) – Noise intensity; each increment has standard deviation sigma * sqrt(dt). Default is 1.0.

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

Variables:
  • n (int) – Number of independent processes

  • t_start (float or Quantity) – Start time of the process

  • t_end (float or Quantity) – End time of the process

  • sigma (float) – Noise intensity

  • seed (int or None) – Random seed for reproducibility

Examples

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

Create simple Wiener process:

>>> noise = WienerProcess(duration=100 * u.ms, sigma=0.5)
>>> signal = noise()

Create multiple independent processes:

>>> multi_noise = WienerProcess(
...     duration=200 * u.ms,
...     n=5,  # 5 independent processes
...     sigma=1.0
... )

Create windowed noise (active only between t_start and t_end):

>>> windowed = WienerProcess(
...     duration=500 * u.ms,
...     sigma=2.0,
...     t_start=100 * u.ms,
...     t_end=400 * u.ms
... )

Combine with other inputs using arithmetic operations:

>>> from braintools.input import Ramp, Step
>>> # Noisy background with linear drift
>>> drift = Ramp(0, 0.5, 500 * u.ms)
>>> noise = WienerProcess(500 * u.ms, sigma=0.1)
>>> drifting_noise = noise + drift

>>> # Modulated noise
>>> envelope = Step([0, 1.0], [0 * u.ms, 100 * u.ms], 500 * u.ms)
>>> modulated = noise * envelope

Create reproducible noise with seed:

>>> fixed_noise = WienerProcess(
...     duration=100 * u.ms,
...     sigma=0.3,
...     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)

  • Useful for modeling synaptic background noise

  • Can be combined with other Input classes using +, -, *, /

See also

OUProcess

Ornstein-Uhlenbeck process with mean reversion

Poisson

Poisson spike train generator

wiener_process

Functional API for Wiener process

__init__(duration, n=1, t_start=None, t_end=None, sigma=1.0, seed=None)[source]#

Initialize the Input base class.

Parameters:

duration (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – The total duration of the input.

Methods

__init__(duration[, n, t_start, t_end, ...])

Initialize the Input base class.

apply(func)

Apply a custom function to the input.

clip([min_val, max_val])

Clip the input values to a range.

generate()

Generate the Wiener process using the functional API.

repeat(n_times)

Repeat the input pattern n times.

scale(factor)

Scale the input by a factor.

shift(time_shift)

Shift the input in time.

smooth(tau)

Apply exponential smoothing to the input.

Attributes

dt

Get the time step from global environment.

n_steps

Get the number of time steps.

shape

Get the shape of the input array.