-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
[resubmitted] Fix poisson deviate for expected values ~> LONG_MAX #34
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
Conversation
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.
I just can't shake the feeling that returning the mean isn't quite the right thing to do. Admittedly, the fractional error is small, but... perhaps we should simply raise an error for anything within 10 sigma of the maximum value. I think you should raise this issue on the mailing list for discussion. If there is a particular reason this has been a problem for you, you should mention that. For the implementation, I think you can import the max integer value from limits.h, something like
You could also compute the square root there. |
I've put up a modified version that just checks for lam too big at charris@c231344. Tests will also be needed. |
I've gone ahead and merged a modified version. Thanks for noting this problem and coming up with a solution. |
DOC: Update docs with Xoshiro additions
* PERF: Reorder header for philox Reorder header so that support uint128 is always used if avilable, irrespective of platform
Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from fa/fix_universal_crashes to labs-hpy-port * commit '3e21b1a35e92fa196650a9a4cf6c438337b5342f': Migrate is_known_scalar_type_function Correctly convert to/from HPyArrayMethod_Context
feat: Add vld1_dup_s8
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.
This patch also adds error checking for when the mean-value cannot be represented by a long integer. In this case, a ValueError is raised with the appropriate error message, similar to how ValueError is raised with the mean-value is specified less than zero.