ENH: Stabilize Poisson computation for large lambda - #32026
Conversation
|
Ping @rkern |
|
This will need a release note to be mergeable. See doc/release/upcoming_changes/README.rst for instructions on how to do that. I'm calling this an enhancement rather than a bugfix since this is a pretty big code change and I'm not sure if it's too risky to backport. Let me know if you think this should be backported. |
|
I’m not sure why the |
rkern
left a comment
There was a problem hiding this comment.
The failures are indeed unrelated, and therefore, happily, someone else's problem!
The code LGTM, thank you! The performance improvement is a nice bonus; thank you for checking. I have a minor request in the release note to raise the salience of the stream-changing effect.
Per NEP 19, we treat these kinds of changes as features rather than bug fixes, so I've slated this for the 2.6.0 release.
PR summary
This PR addresses #31986 by implementing a stable calculation of Poisson log-PMF, adapted from dbinom.c.
It is about approximately 10% faster on average (only tested on my system) and does not suffer from instabilities at larger$$\lambda$$ , as seen by this plot created by benchmark_poisson_ptrs.py.
First time committer introduction
I’m interested in contributing to open-source software, and this is my first pull request to NumPy. I hope to continue contributing in the future. I’d be grateful for any feedback from the maintainers.
AI Disclosure
I used Codex Sol Light to check the port of the code discussed in the original issue, and to create the benchmarking script. The submitted C changes and regression test were prepared with this assistance and reviewed and tested by me.