nstat.simulate_point_process

nstat.simulate_point_process(time, rate_hz, *, seed=None, uniform_values=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) (dt is 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.

  • seed (int, optional) – Seed for numpy.random.default_rng when uniform_values is not given.

  • uniform_values (array_like, shape (n,), optional) – Pre-drawn uniform variates in [0, 1), for deterministic reproduction. When given, seed is ignored.

Returns:

Bundle with the time grid, rate, realised spikes, per-bin spike probability lambda_delta, binary spike_indicator and the uniform_values actually used. When fewer than two time samples are given, the spike train is empty.

Return type:

PointProcessSimulation

Raises:

ValueError – If time and rate_hz differ in length, or uniform_values does not match the length of time.