-
Notifications
You must be signed in to change notification settings - Fork 221
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
Fix for issue 845 #846
Merged
Merged
Fix for issue 845 #846
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright Matt Borland, 2022 | ||
// Use, modification and distribution are subject to the | ||
// Boost Software License, Version 1.0. (See accompanying file | ||
// LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <cfenv> | ||
#include <iostream> | ||
#include <boost/math/distributions/non_central_f.hpp> | ||
#include "math_unit_test.hpp" | ||
|
||
#pragma STDC FENV_ACCESS ON | ||
|
||
int main() | ||
{ | ||
auto ncf1 = boost::math::non_central_f(2, 2, 2); | ||
const auto cdf1 = boost::math::cdf(ncf1, 0.05); | ||
|
||
// https://www.wolframalpha.com/input?i=N%5BCdf%28NonCentralFRatioDistribution%282%2C2%2C2%29%2C+0.05%29%2C+15%5D | ||
CHECK_ULP_CLOSE(cdf1, 0.0183724431823392, 15); | ||
|
||
if (std::fetestexcept(FE_INVALID) || std::fetestexcept(FE_DIVBYZERO)) | ||
{ | ||
return 1; | ||
} | ||
|
||
auto ncf2 = boost::math::non_central_f(1, 3, 2); | ||
const auto cdf2 = boost::math::cdf(ncf2, 0.05); | ||
|
||
// https://www.wolframalpha.com/input?i=N%5BCdf%28NonCentralFRatioDistribution%281%2C3%2C2%29%2C+0.05%29%2C+15%5D | ||
CHECK_ULP_CLOSE(cdf2, 0.0611253404710995, 15); | ||
|
||
if (std::fetestexcept(FE_INVALID) || std::fetestexcept(FE_DIVBYZERO)) | ||
{ | ||
return 2; | ||
} | ||
|
||
auto ncf3 = boost::math::non_central_f(1, 1, 2); | ||
const auto cdf3 = boost::math::cdf(ncf3, 0.05); | ||
|
||
// https://www.wolframalpha.com/input?i=N%5BCdf%28NonCentralFRatioDistribution%281%2C1%2C2%29%2C+0.05%29%2C+15%5D | ||
CHECK_ULP_CLOSE(cdf3, 0.0531991288870987, 15); | ||
|
||
if (std::fetestexcept(FE_INVALID) || std::fetestexcept(FE_DIVBYZERO)) | ||
{ | ||
return 3; | ||
} | ||
|
||
const auto pdf3 = boost::math::pdf(ncf3, 0.05); | ||
|
||
// https://www.wolframalpha.com/input?i=N%5BPdf%28NonCentralFRatioDistribution%281%2C1%2C2%29%2C+0.05%29%2C+15%5D | ||
CHECK_ULP_CLOSE(pdf3, 0.547785080683644, 15); | ||
|
||
if (std::fetestexcept(FE_INVALID) || std::fetestexcept(FE_DIVBYZERO)) | ||
{ | ||
return 4; | ||
} | ||
|
||
return boost::math::test::report_errors(); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Rather than putting an
if
inside the inner loop, it would be better to move calculation of xterm to the start of the loop: albeit it's inconvenient, and we have to be careful to get the algebra right ;)Again this should wait till after the next release.