spiketools.stats.generators.poisson_generator

spiketools.stats.generators.poisson_generator(rate, duration, start_time=0)[source]

Generator function for a Homogeneous Poisson distribution.

Parameters:
ratefloat

The average rate for the generator.

durationfloat

Maximum duration. After this time, the generator will return.

start_time: float, optional

Timestamp of the start time for the generated sequence.

Yields:
float

A sample from the distribution. Sample is a relative value, based on start_time, in seconds.

Examples

Create a Poisson generator and sample from it:

>>> gen = poisson_generator(20, duration=np.inf)
>>> for ind in range(10):
...     sample = next(gen)