-
Notifications
You must be signed in to change notification settings - Fork 248
Initial implementation of find_non_centrality for non_central_f_distribution
#1345
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
base: develop
Are you sure you want to change the base?
Conversation
|
@dschmitz89 how does this first commit look in regards to #1338 (comment) |
find_non_centrality for non_central_f_distribution [skip ci]find_non_centrality for non_central_f_distribution
|
Thanks @JacobHass8 for looking into this so quickly. This is a good start. I am not a boost maintainer (barely a boost developer), so can only comment from a high level. The most important missing bit here is tests for the new functionality. I could not find the current noncentral F distribution tests after 2 minutes though, so we will have to rely on the boost devs to guide us a little here. |
|
Yup, tests needed. Non central F is treated as a special case of the non-central beta (which is where most of the tests are). Non-central F tests are fairly lightweight, just there to make sure we have the transformation to non-central beta correct really: https://github.com/boostorg/math/blob/develop/test/test_nc_f.cpp. A similar level of sanity checking would probably suffice for this function I would guess? |
I've added a couple of tests and documentation. The tests and documentation copy what is done for the |
|
@jzmaddock could I get a review on this when you get the chance? Are there any test cases that you can think of that I should add? |
mborland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me. I made a couple minor changes to get it running with CUDA. Since scipy already has an implementation, it's probably worth copying over any tests they have as well.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1345 +/- ##
========================================
Coverage 95.29% 95.30%
========================================
Files 814 814
Lines 67422 67461 +39
========================================
+ Hits 64249 64292 +43
+ Misses 3173 3169 -4
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
SciPy does not have tests for these functions at the moment yet. The functions were simply incorporated a long time ago with the cdflib library but actually never unit tested. One more plus point for the migration we are planning. |
There's actually a couple here. It's only really 3 spot checks. I could add some edge case testing like what happens if |
Ah, thanks for spotting those. The file where the function is supposed to be tested, lists it as untested. About tests here: as long as boost maintainers are happy, it should be good. In SciPy, we do not need to test the function very extensively if it is already thoroughly tested in boost (although one never knows in future, SciPy has demanding users .. ). |
I think adding all of these makes sense. As @dschmitz89 alluded to, the SciPy users are pretty adept at finding weakness in our edge cases when they exist. |
|
All the tests are passing except for g++-14 c++23 autodiff which appears to be unrelated to this PR. The error is below. Details
unknown location(0): fatal error: in "test_autodiff_8/heuman_lambda_hpp<_Float32>": Throw location unknown (consider using BOOST_THROW_EXCEPTION)
Dynamic exception type: boost::wrapexcept<std::domain_error>
std::exception::what: Error in function boost::math::heuman_lambda<N5boost4math15differentiation11autodiff_v16detail4fvarIDF32_Lm5EEE>(N5boost4math15differentiation11autodiff_v16detail4fvarIDF32_Lm5EEE, N5boost4math15differentiation11autodiff_v16detail4fvarIDF32_Lm5EEE): When 1-k^2 == 1 then phi must be < Pi/2, but got phi = depth(1)(4.20396852,1,0,0,0,0)
test_autodiff_8.cpp(38): last checkpoint
*** 1 failure is detected in the test module "test_autodiff" |
I've added tests to make sure that fisher_f_distribution<RealType, Policy> dist(v1, v2);
if (boost::math::relative_difference(pdf(dist, x), p) < 1e-7){
return 0;
}I first tried a relative difference of |
See #1305 for for details.