Skip to content

[FIX] Add t_start to the first spike of StationaryPoissonProcess with refractory period - #734

Open
chenyangsu wants to merge 1 commit into
NeuralEnsemble:masterfrom
chenyangsu:fix/poisson-dead-time-first-spike-t-start
Open

chenyangsu wants to merge 1 commit into
NeuralEnsemble:masterfrom
chenyangsu:fix/poisson-dead-time-first-spike-t-start

Conversation

@chenyangsu

Copy link
Copy Markdown

StationaryPoissonProcess(rate=20*pq.Hz, t_start=5000*pq.ms, t_stop=10000*pq.ms, refractory_period=3*pq.ms).generate_spiketrain() raises ValueError: The first spike (...) is before t_start (5000.0), and with as_array=True the spikes start near 0 ms. In _get_first_spike_equilibrium, the dead-time branch returns the latency without self._t_start, while the other two branches add it.

The fix adds self._t_start there. The new test checks that 1000 first spikes fall after t_start, with mean latency near the renewal-theory value E[ISI²]/(2 E[ISI]) = 47.1 ms. The unseeded test_t_start_and_t_stop (t_start=17 ms) failed in about 15% of runs on master for the same reason.

Testing: pytest elephant/test/test_spike_train_generation.py -> 59 passed. The new test fails on master.

@CozySocksAlways

Copy link
Copy Markdown
Contributor

Hi @chenyangsu, Thanks for this fix, we'll take a look soon.
A heads-up for future contributions: we're updating our contribution guide, and from now on we'll ask contributors to open an issue first and wait for a maintainer to agree before opening a pull request. This lets us agree on scope and approach early, so nobody's effort is wasted. The updated guide will be published soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants