-
Notifications
You must be signed in to change notification settings - Fork 419
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
Quantile: Newton: introduce oscillation dampening #1899
base: master
Are you sure you want to change the base?
Conversation
This is what the `quantile_newton()`/`cquantile_newton()` does, because otherwise they were able to end up in an endless loops, when the initial point and the mode are the same, see JuliaStats#666. I'm not sure this is needed here, but the next change is going to refactor them to use general `newton()`, which would make this change anyway, so unless we need the current behaviour, let's do this change explicitly.
c8a2ae1
to
b0bc737
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1899 +/- ##
==========================================
- Coverage 85.99% 85.94% -0.05%
==========================================
Files 144 144
Lines 8666 8668 +2
==========================================
- Hits 7452 7450 -2
- Misses 1214 1218 +4 ☔ View full report in Codecov by Sentry. |
Thank you for the PR! My general feeling though is that we should not re-invent and re-implement numerical algorithms that already exist and are better maintained in other packages such as Roots.jl. This also has the additional benefit that all other dependencies and users can benefit from any improvements or modifications possibly needed for Distributions. |
Sure, let me see what i can do... |
It is well known that Newton's method has an oscillation problem.
In fact, it can reasonably happen on real-world, non-synthetic,
distributions, when computing quantiles.
This situation appears easy to detect - just check that we've converged
with the root we had two steps ago - i may be mistaken, but i'm not sure
this can happen in any situation other than during oscillation.
Likewise, it appears to be easily circumventable,
by picking a new x0 in-between the oscillation bounds,
by using just half of the delta-x we'd apply otherwise.
NOTE: i do not have a proof that this solves all the issues,
does not introduce new ones, nor do i know that the choice of,
specifically, half of the delta-x is optimal.
Fixes #1571
Fixes #1833
Fixes #1898