braintools.input.Poisson#
- class braintools.input.Poisson(rate, duration, n=1, t_start=None, t_end=None, amplitude=1.0, seed=None)#
Generate Poisson spike train input.
Creates spike trains where spikes occur randomly according to a Poisson process with a specified rate. This is useful for modeling random synaptic inputs or background activity in neural systems.
The probability of a spike in each time bin is:
\[P(\text{spike}) = \lambda \cdot dt\]where λ is the rate and dt is the time step.
- Parameters:
rate (
Quantity) – Mean firing rate. Must be in Hz units.duration (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Total duration of the input signal. Supports time units.n (
int) – Number of independent Poisson processes to generate. Default is 1.t_start (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Start time of spiking. Before this, output is 0. Default is 0.t_end (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – End time of spiking. After this, output is 0. Default is duration.amplitude (
float) – Amplitude of each spike. Default is 1.0.seed (
int|None) – Random seed for reproducibility. Default is None (uses global random state).
- rate#
Firing rate in Hz
- Type:
Quantity
Examples
>>> import brainunit as u >>> import brainstate >>> brainstate.environ.set(dt=0.1 * u.ms)
Simple Poisson spike train:
>>> spikes = Poisson( ... rate=10 * u.Hz, ... duration=1000 * u.ms ... ) >>> signal = spikes()
High-frequency background activity:
>>> background = Poisson( ... rate=100 * u.Hz, ... duration=500 * u.ms, ... amplitude=0.5 # Smaller amplitude ... )
Multiple independent spike trains:
>>> multi_spikes = Poisson( ... rate=20 * u.Hz, ... duration=2000 * u.ms, ... n=50, # 50 independent spike trains ... amplitude=2.0 ... )
Windowed spiking activity:
>>> burst = Poisson( ... rate=50 * u.Hz, ... duration=1000 * u.ms, ... t_start=200 * u.ms, ... t_end=800 * u.ms, ... amplitude=1.0 ... )
Low rate spontaneous activity:
>>> spontaneous = Poisson( ... rate=1 * u.Hz, ... duration=10000 * u.ms, ... amplitude=5.0 ... )
Combine with envelopes for rate modulation:
>>> from braintools.input import GaussianPulse, Sinusoidal >>> # Poisson spikes with Gaussian envelope >>> poisson = Poisson(50 * u.Hz, 1000 * u.ms) >>> envelope = GaussianPulse(1.0, 500 * u.ms, 100 * u.ms, 1000 * u.ms) >>> modulated = poisson * envelope >>> # Rhythmic modulation of spike rate >>> rhythm = Sinusoidal(0.5, 5 * u.Hz, 1000 * u.ms) >>> rhythmic_spikes = poisson * (1 + rhythm)
Create reproducible spike pattern:
>>> fixed_spikes = Poisson( ... rate=30 * u.Hz, ... duration=500 * u.ms, ... seed=456 # Fixed seed for reproducibility ... )
Inhomogeneous Poisson process (time-varying rate):
>>> from braintools.input import Ramp >>> # Base Poisson process >>> base_poisson = Poisson(10 * u.Hz, 1000 * u.ms) >>> # Increasing rate envelope >>> ramp = Ramp(0.1, 1.0, 1000 * u.ms) >>> increasing_rate = base_poisson * ramp
Notes
Spike probability per timestep = rate * dt
Mean number of spikes = rate * duration
Inter-spike intervals follow exponential distribution
For small dt, probability of multiple spikes per bin is negligible
Can be combined with continuous inputs for rate modulation
Useful for modeling synaptic background noise
Can be combined with other Input classes using +, -, *, /
See also
WienerProcessContinuous noise process
OUProcessOrnstein-Uhlenbeck process
poissonFunctional API for Poisson input
- __init__(rate, duration, n=1, t_start=None, t_end=None, amplitude=1.0, seed=None)[source]#
Initialize the Input base class.
Methods
__init__(rate, duration[, n, t_start, ...])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 Poisson input 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.