Skip to content
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

Wrong results #21

Closed
laxris opened this issue Aug 26, 2020 · 2 comments
Closed

Wrong results #21

laxris opened this issue Aug 26, 2020 · 2 comments

Comments

@laxris
Copy link

laxris commented Aug 26, 2020

We've been using the chi-squared distribution function, and it seems to give us wrong answers. We've compared with the libgsl implementation, and it seems that for many cases, pchisq is just wrong.

For example, test_statistic = 10605, extra_parameters = 9

double p_value1 = 1.0 - gsl_cdf_chisq_P (test_statistic, (double)extra_parameters);
double p_value2 = gsl_cdf_chisq_Q (test_statistic, (double)extra_parameters);
double p_value = 1.0 - stats::pchisq(test_statistic, extra_parameters, false);

p_value is 0, but p_value1 = 1, which is the correct answer. Any ideas what's going on? Are we using it wrong?

Edit: It seems like values lower than 0.05 are often wrong.

@kthohr
Copy link
Owner

kthohr commented Aug 27, 2020

Thanks for the bug report. This was due to an overflow in the gcem::incomplete_gamma function. Should be fixed now, but let me know if it isn't.

@laxris
Copy link
Author

laxris commented Aug 27, 2020

Amazing, that seems to fix the issue indeed. Thanks a lot!

@laxris laxris closed this as completed Aug 27, 2020
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

No branches or pull requests

2 participants