nstat.simulate_poisson_from_rate
- nstat.simulate_poisson_from_rate(time, rate_hz, rng=None)[source]
Simulate one spike train from a sampled rate by per-bin Bernoulli sampling.
In each time bin the spike probability is
1 - exp(-rate_hz * dt)(dtis the local bin width; the last bin reuses the previous width). A spike is emitted, stamped at the bin’s time value, when a uniform draw falls below that probability.- Parameters:
time (array_like, shape (n,)) – Monotonic time grid in seconds.
rate_hz (array_like, shape (n,)) – Conditional intensity in Hz on the same grid. Negative values are treated as zero.
rng (numpy.random.Generator, optional) – Random generator used for the draws. A fresh
numpy.random.default_rng()is created when omitted (not reproducible); passnp.random.default_rng(seed)for repeatable output.
- Returns:
Simulated spike train. It is empty when fewer than two time samples are given.
- Return type:
- Raises:
ValueError – If
timeandrate_hzdiffer in length.