PoissonEncoder#
- class braintools.spike.PoissonEncoder(time_window=None, normalize=False, max_rate=100.0)#
Encode inputs as Poisson spike trains.
The input sets the rate of a Poisson process. In each time step the number of events is drawn from a Poisson distribution with mean \(\lambda = \text{rate} \cdot dt\) (with \(dt\) the
brainstate.environtime step), and the step spikes when that number is positive, i.e. with probability \(1 - e^{-\lambda}\).- Parameters:
time_window (
float|None) – Deprecated since 0.4.0 and unused (removed in 1.0.0); passing it emits aBraintoolsDeprecationWarning. The rate is set by the input (Hz) and thebrainstatetime step.normalize (
bool) – If False, inputs are rates in Hz. If True, inputs are fractions ofmax_rate.max_rate (
float) – Rate in Hz for an input of 1 whennormalize=True.
See also
RateEncoderMaps inputs to rates and fires with probability
rate * dt.BernoulliEncoderSets the spike probability per time step directly.
Examples
>>> import brainstate >>> import brainunit as u >>> import jax.numpy as jnp >>> import braintools >>> brainstate.environ.set(dt=1. * u.ms) >>> brainstate.random.seed(0) >>> rates = jnp.array([10.0, 50.0, 100.0]) # Hz >>> spikes = braintools.spike.PoissonEncoder()(rates, n_time=1000) # 1 s >>> spikes.shape (1000, 3) >>> counts = spikes.sum(axis=0) # approximately [10, 50, 100] spikes