PoissonEncoder#
- class brainpy.state.PoissonEncoder(in_size, spk_type=<class 'bool'>, name=None)#
Poisson spike encoder for converting firing rates to spike trains.
This class implements a Poisson process to generate spikes based on provided firing rates. Unlike the PoissonSpike class, this encoder accepts firing rates as input during the update step rather than having them fixed at initialization.
The spike generation follows a Poisson process where the probability of a spike in each time step is proportional to the firing rate and the simulation time step:
\[ P(\text{spike}) = \text{rate} \cdot \text{dt} \]For each neuron and time step, the encoder draws a random number from a uniform distribution [0,1] and generates a spike if the number is less than or equal to the spiking probability.
- Parameters:
See also
PoissonSpikePoisson generator with fixed firing rates.
PoissonInputEfficient Poisson input applied directly to a state.
Notes
This encoder is particularly useful for rate-to-spike conversion in neuromorphic computing applications and sensory encoding tasks.
The statistical properties of the generated spike trains follow a Poisson process, where the inter-spike intervals are exponentially distributed.
For small time steps (dt), the number of spikes in a time window T approximately follows a Poisson distribution with parameter λ = rate * T.
Unlike PoissonSpike which has fixed rates, this encoder allows dynamic rate changes with every update call, making it suitable for encoding time-varying signals.
The independence of spike generation between time steps results in renewal process statistics without memory of previous spiking history.
References
Examples
>>> import brainpy >>> import brainstate >>> import saiunit as u >>> import numpy as np >>> >>> # Create a Poisson encoder for 10 neurons >>> encoder = brainpy.state.PoissonEncoder(10) >>> >>> # Generate spikes with varying firing rates >>> rates = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) * u.Hz >>> spikes = encoder.update(rates) >>> >>> # Use in a more complex processing pipeline >>> # First, generate rate-coded output from an analog signal >>> analog_values = np.random.rand(10) * 100 # values between 0 and 100 >>> firing_rates = analog_values * u.Hz # convert to firing rates >>> spike_train = encoder.update(firing_rates) >>> >>> # Feed the spikes into a spiking neural network >>> neuron_layer = brainpy.state.LIF(10) >>> neuron_layer.init_state(batch_size=1) >>> output_spikes = neuron_layer.update(spike_train)