Skip to content

Fix poisson deviate for expected values ~> LONG_MAX #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Fix poisson deviate for expected values ~> LONG_MAX #29

wants to merge 1 commit into from

Conversation

olsonse
Copy link

@olsonse olsonse commented Dec 27, 2010

This patch causes rk_poisson to simply return the mean value of the Poissonian when the distribution cannot be supported by the high-order bits of the long integer type. This patch simply checks whether the mean value is less than LONG_MAX - 10 * sqrt(LONG_MAX) before actually generating a random deviate. This ensures that at least 20*sigma (sigma=sqrt(mean value)) of width for the distribution--this should be plenty of width.

Since we can't support a complete poissonian disribution for values on the order
and greater than LONG_MAX, we simply return the expected value for these very
large expected values.
@charris
Copy link
Member

charris commented Jan 9, 2011

What if lambda itself exceeds the maximum value than can be held in a long? Maybe an error needs to be raised somewhere, although I don't see how, there is no error return available. There is a small logic error also. I think this patch needs a bit of work still.

@olsonse
Copy link
Author

olsonse commented Jan 10, 2011

I've fixed the logic error in and added in error checking (inside mtrand.pyx). I'll issue a new pull request...

mattip referenced this pull request in mattip/numpy Mar 20, 2019
fangerer added a commit to hpyproject/numpy-hpy that referenced this pull request Jul 7, 2022
…iscoverDTypeAndShape

Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from fa/PyArray_Pack to labs-hpy-port

* commit 'b2c1d7edcc1242e1397ae292c784c2a791bc4fa2':
  Fix some warnings due to legacy function signature
  Migrate function signature PyArray_SetItemFunc
  Migrate PyArray_DiscoverDTypeAndShape
  Use HPyDict_GetItem to ignore error context
  Migrate PyArray_Pack
luyahan pushed a commit to plctlab/numpy that referenced this pull request Apr 25, 2024
test: Use self-maintained GNU toolchain binary
This pull request was closed.
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