-
Couldn't load subscription status.
- Fork 164
Changed the tolerance on convergence in normal_distribution_mod::inv_cdf #893
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
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.
Pull Request Overview
Adjust the convergence logic in first_guess for the inverse CDF computation to improve stability and add an early exit when the initial guess is exact.
- Introduce a new
epsilon_exponentparameter (0.52) to bound convergence instead of the hardcoded 0.75. - Add an early return if the preliminary quantile guess exactly matches the target.
- Update the convergence check to use the new
epsilon_exponent.
Comments suppressed due to low confidence (2)
assimilation_code/modules/assimilation/normal_distribution_mod.f90:405
- Add a unit test to cover the branch where the preliminary guess exactly matches the quantile, ensuring the early return path is exercised.
if(del_q == 0.0_r8) then
assimilation_code/modules/assimilation/normal_distribution_mod.f90:358
- [nitpick] The name
epsilon_exponentcould be more descriptive (e.g.,convergence_epsilon_exponent) to better convey its purpose in the convergence check.
real(r8), parameter :: epsilon_exponent = 0.52_r8
| ! If the preliminary guess is exact, no need to do iterative search below | ||
| if(del_q == 0.0_r8) then |
Copilot
AI
Jun 9, 2025
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.
Avoid direct equality comparison on floating-point values as it can be unreliable; consider using a small tolerance (e.g., ABS(del_q) <= tol) to determine exact matches.
| ! If the preliminary guess is exact, no need to do iterative search below | |
| if(del_q == 0.0_r8) then | |
| ! If the preliminary guess is sufficiently close, no need to do iterative search below | |
| tol = 1.0e-12_r8 ! Define a small tolerance for floating-point comparison | |
| if(ABS(del_q) <= tol) then |
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.
Yeah I know copilot this is all over the code
-Wcompare-reals for distribution mods
#717 (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.
see #894 for list of real comparisons.
|
rebasing this pull request. |
Tuned this value from 0.75 to 0.52 to avoid previous failure to converge error messages. This version passes the normal, beta and gamma developers tests for the following compilers on Derecho with the standard mkmf files: gcc 12.4.0 gcc 12.2.0 gcc 13.2.0 ifort 2024.2 ifx 2025.0.3 nvidia 24.11 It passed all tests except the second set of convergence tests for the beta distribution for the Cray cce 17.0.1. That compiler crashed for the second part of the beta tests, likely due to a compiler error. It passed all three tests on a mac with gfortran 13.3.0 with -O0, -O1, -O2 and -O3.
Co-authored-by: Jeff Anderson [email protected]
3207919 to
0b6a82b
Compare
|
@jlaucar checking in on this, do you have an estimate of when you will get to the review? |
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 good to go. It does have potential to generate results that are not backwards compatible.
|
@mjs2369 can you click "approve" on this, see Jeff's "approve comment |
|
Approved. |
|
I guess I don't know how to do this. I wrote "approved" as a comment and
submitted. Was that what was needed?
…On Mon, Aug 25, 2025 at 7:06 AM Helen Kershaw ***@***.***> wrote:
*hkershaw-brown* left a comment (NCAR/DART#893)
<#893 (comment)>
@mjs2369 <https://github.com/mjs2369> can you click "approve" on this,
see Jeff's "approve comment
#893 (review)
<#893 (review)>
—
Reply to this email directly, view it on GitHub
<#893 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANDHUIXKH4KEOZ2GNP7BO4D3PMC5VAVCNFSM6AAAAAB65MEZDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMRQGE4TMNZXG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description:
Changes the tolerance on convergence in normal_distribution_mod::inv_cdf
Now a parameter and set to epsilon_exponent = 0.52_r8
Previous value of 0.75 leads to failure to converge for some compilers.
This pull request also adds a return early if the first guess is exact.
Fixes issue
fixes #873
Types of changes
Performance fix really.
Documentation changes needed?
Tests
Please describe any tests you ran to verify your changes.
jla testing on Dercho compilers.
Checklist for merging
Checklist for release
Testing Datasets