braintools.input.poisson

Contents

braintools.input.poisson#

braintools.input.poisson(rate, duration, amplitude=1.0, n=1, t_start=None, t_end=None, seed=None)#

Generate Poisson spike train input.

Creates spike trains where spikes occur randomly according to a Poisson process with a specified rate. Useful for modeling random synaptic inputs or background activity.

Parameters:
  • rate (Array | ndarray | bool | number | bool | int | float | complex | 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.

  • amplitude (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Amplitude of each spike. Supports current units. Default is 1.0.

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

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

Returns:

current – The Poisson spike train input. Shape is (n_timesteps,) if n=1, or (n_timesteps, n) if n>1.

Return type:

ndarray or Quantity

Raises:

AssertionError – If rate is not in Hz units.

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,
...     amplitude=1 * u.pA
... )

High-frequency background activity

>>> spikes = poisson(
...     rate=100 * u.Hz,
...     duration=500 * u.ms,
...     amplitude=0.5 * u.nA
... )

Multiple independent spike trains

>>> spikes = poisson(
...     rate=20 * u.Hz,
...     duration=2000 * u.ms,
...     amplitude=2 * u.pA,
...     n=50  # 50 independent spike trains
... )

Windowed spiking activity

>>> spikes = poisson(
...     rate=50 * u.Hz,
...     duration=1000 * u.ms,
...     amplitude=1 * u.nA,
...     t_start=200 * u.ms,
...     t_end=800 * u.ms
... )

Low rate spontaneous activity

>>> spikes = poisson(
...     rate=1 * u.Hz,
...     duration=10000 * u.ms,
...     amplitude=5 * u.pA,
...     seed=123  # Reproducible spike pattern
... )

Notes

  • Spike probability per timestep = rate * dt

  • Mean number of spikes = rate * duration

  • Inter-spike intervals follow exponential distribution

  • Useful for modeling synaptic background noise