PoissonInput

Contents

PoissonInput#

class brainpy.state.PoissonInput(target, indices, num_input, freq, weight, name=None)#

Poisson Input to the given state variable.

This class provides a way to add independent Poisson-distributed spiking input to a target state variable. For large numbers of inputs, this implementation is computationally more efficient than creating separate Poisson spike generators.

The synaptic events are generated randomly during simulation runtime and are not preloaded or stored in memory, which improves memory efficiency for large-scale simulations. All inputs target the same variable with the same frequency and synaptic weight.

The Poisson process generates spikes with probability based on the frequency and simulation time step:

\[ P(\text{spike}) = \text{freq} \cdot \text{dt} \]

For computational efficiency, two different methods are used for spike generation:

  1. For large numbers of inputs, a normal approximation:

    \[ \text{inputs} \sim \mathcal{N}(\mu, \sigma^2) \]
    where \(\mu = \text{num\_input} \cdot p\) and \(\sigma^2 = \text{num\_input} \cdot p \cdot (1-p)\)

  2. For smaller numbers, a direct binomial sampling:

    \[ \text{inputs} \sim \text{Binomial}(\text{num\_input}, p) \]

where \(p = \text{freq} \cdot \text{dt}\) in both cases.

Parameters:
  • target (brainstate.nn.Prefetch) – The variable that is targeted by this input. Should be an instance of brainstate.State that’s brainstate.nn.Prefetched via the target mechanism.

  • indices (Union[np.ndarray, jax.Array]) – Indices of the target to receive input. If None, input is applied to the entire target.

  • num_input (int) – The number of independent Poisson input sources.

  • freq (Union[int, float]) – The firing frequency of each input source in Hz.

  • weight (ndarray, float, or saiunit.Quantity) – The synaptic weight of each input spike.

  • name (Optional[str], optional) – The name of this brainstate.nn.Module.

See also

PoissonSpike

Poisson spike generator as a neuron group.

PoissonEncoder

Poisson encoder for rate-to-spike conversion.

poisson_input

Functional version of Poisson input generation.

Notes

  • The Poisson inputs are statistically independent between update steps and across target neurons.

  • This implementation is particularly efficient for large numbers of inputs or targets.

  • For very sparse connectivity patterns, consider using individual PoissonSpike neurons with specific connectivity patterns instead.

  • The update method internally calls the poisson_input function which handles the spike generation and target state updates.

Examples

>>> import brainpy
>>> import brainstate
>>> import saiunit as u
>>> import numpy as np
>>>
>>> # Create a neuron group with membrane potential
>>> neuron = brainpy.state.LIF(100)
>>> neuron.init_state(batch_size=1)
>>>
>>> # Add Poisson input to all neurons
>>> poisson_in = brainpy.state.PoissonInput(
...     target=neuron.V,
...     indices=None,
...     num_input=200,
...     freq=50 * u.Hz,
...     weight=0.1 * u.mV
... )
>>>
>>> # Add Poisson input only to specific neurons
>>> indices = np.array([0, 10, 20, 30])
>>> specific_input = brainpy.state.PoissonInput(
...     target=neuron.V,
...     indices=indices,
...     num_input=50,
...     freq=100 * u.Hz,
...     weight=0.2 * u.mV
... )
>>>
>>> # Run simulation with the inputs
>>> for t in range(100):
...     poisson_in.update()
...     specific_input.update()
...     neuron.update()