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 (Brownian motion) input.

Creates a stochastic input following a Wiener process, where increments are drawn from a normal distribution N(0, σ²dt). Useful for modeling synaptic noise or random fluctuations in neural systems.

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) – Standard deviation of the noise. 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 Wiener process input. 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
>>> 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

  • The variance scales with dt: Var(dW) = σ²dt

  • The process has zero mean: E[W(t)] = 0

  • Increments are independent and normally distributed