Fixes numerical accuracy issues in quantile.#16572
Merged
andreasnoack merged 1 commit intomasterfrom May 26, 2016
Merged
Conversation
Fixes issue JuliaStats/StatsBase.jl#164, and another when `p < eps()`.
Member
Author
|
cc @andreasnoack can you review and merge? |
|
|
||
| indlo = floor(index) | ||
| i = trunc(Int,indlo) | ||
| i = trunc(Int,t0) + 1 |
Member
There was a problem hiding this comment.
To avoid confusion, maybe just t0 = Int(f0) since f0 has already been truncated.
Member
Author
There was a problem hiding this comment.
trunc(Int, t0) is technically faster, as it avoids the check of an integer.
Member
|
Except for the minor comment, it looks good. |
nalimilan
added a commit
to JuliaStats/Statistics.jl
that referenced
this pull request
Jul 1, 2023
The `a + γ*(b-a)` introduced by JuliaLang/julia#16572 has the advantage that it increases with `γ` even when `a` and `b` are very close, but it has the drawback that it is not robust to overflow. This is likely to happen in practice with small integer and floating point types. Conversely, the `(1-γ)*a + γ*b` which is currently used only for non-finite quantities is robust to overflow but may not always increase with `γ` as when `a` and `b` are very close or (more frequently) equal since precision loss can give a slightly smaller value for a larger `γ`. This can be problematic as it breaks an expected invariant. So keep using the `a + γ*(b-a)` formula when `a ≈ b`, in which case it's almost like returning either `a` or `b` but less arbitrary.
nalimilan
added a commit
to JuliaStats/Statistics.jl
that referenced
this pull request
Jul 29, 2023
The `a + γ*(b-a)` introduced by JuliaLang/julia#16572 has the advantage that it increases with `γ` even when `a` and `b` are very close, but it has the drawback that it is not robust to overflow. This is likely to happen in practice with small integer and floating point types. Conversely, the `(1-γ)*a + γ*b` which is currently used only for non-finite quantities is robust to overflow but may not always increase with `γ` as when `a` and `b` are very close or (more frequently) equal since precision loss can give a slightly smaller value for a larger `γ`. This can be problematic as it breaks an expected invariant. So keep using the `a + γ*(b-a)` formula when `a ≈ b`, in which case it's almost like returning either `a` or `b` but less arbitrary.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes issue JuliaStats/StatsBase.jl#164, and another when
p < eps().