braintools.input.WienerProcess#
- class braintools.input.WienerProcess(duration, n=1, t_start=None, t_end=None, sigma=1.0, seed=None)#
Generate Wiener process (Brownian motion) input.
A Wiener process (also known as Brownian motion) is a continuous-time stochastic process with independent Gaussian increments. It’s widely used to model synaptic noise and random fluctuations in neural systems.
The process follows:
\[dW(t) \sim \mathcal{N}(0, \sigma^2 dt)\]where increments are independent and normally distributed.
- 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) – Standard deviation of the noise. Default is 1.0.seed (
int|None) – Random seed for reproducibility. Default is None (uses global random state).
Examples
>>> import brainunit as u >>> import brainstate >>> 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
The variance of increments scales with dt: Var(dW) = σ²dt
The process has zero mean: E[W(t)] = 0
Increments are independent and normally distributed
The process is non-differentiable but continuous
Useful for modeling synaptic background noise
Can be combined with other Input classes using +, -, *, /
See also
OUProcessOrnstein-Uhlenbeck process with mean reversion
PoissonPoisson spike train generator
wiener_processFunctional 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.
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
dtGet the time step from global environment.
n_stepsGet the number of time steps.
shapeGet the shape of the input array.