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
cdf never yields result for certain input #7
Comments
|
Thanks for this. I confirmed the issue. The input needs to be numeric and finite -- not strings. Finding the cdf quickly involves bisection and code like this: cumulative-distribution-function/index.js Line 35 in afaf917
As you may know, in JS "2"+"2" === "22" and with numbers it is 4 (on most days). Extracting the numeric data seems to fix your example and yields |
|
Notes to self: A fix should aim to eliminate the use of improper data as a denial-of-service attack against an app using the cdf() functionality. cumulative-distribution-function/index.js Line 13 in 7c5d951
It is already doing a copy of the data array internally; that copy already costs time and memory. Converting numeric strings and eliminating non-numeric data in a copy of the data is probably not a terrible idea. |
|
Thanks for pointing out the cause! I agree that a check there would be appropriate. |
misc tests for data validity and avoiding issue #7 by failing early
The Ensure numeric PR checks for clean data and fixes issue #7
|
The fixed version, v2, will be live on NPM within 24 hours. |
Hi,
thanks you for providing this package. Given a specific data set we found that the function is stuck in a while loop. This can be reproduced reliably through the following example:
I hope you find this useful.
The text was updated successfully, but these errors were encountered: