Poisson Rate Algorithm

poisson_rate(signal: ndarray, interval_length: int, seed: int = 0) ndarray[source]

Perform Poisson rate encoding on the input signal.

This function generates a spike train using a Poisson distribution, where the probability of emitting a spike in a given interval is determined by the normalized rate of the signal.

See the Poisson Rate Encoding description for a detailed explanation of the Poisson rate encoding algorithm.

Code Example:

import numpy as np
from spikify.encoding.rate import poisson_rate
signal = np.array([0.2, 0.5, 0.8, 1.0])
np.random.seed(0)
interval_length = 2
encoded_signal = poisson_rate(signal, interval_length)
Parameters:
  • signal (numpy.ndarray) – The input signal to be encoded. This should be a numpy ndarray.

  • interval_length (int) – The size of the interval for encoding the spike train.

  • seed (int) – Random seed for reproducibility. Default is 0.

Returns:

A numpy array of encoded spike data after Poisson rate encoding.

Return type:

numpy.ndarray

Raises:
  • ValueError – If the input signal is empty.

  • ValueError – If the interval is not a factor of the signal length.

  • TypeError – If the signal is not a numpy.ndarray