Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2055 +/- ##
==========================================
- Coverage 86.62% 86.54% -0.08%
==========================================
Files 148 148
Lines 8903 8928 +25
==========================================
+ Hits 7712 7727 +15
- Misses 1191 1201 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Author
|
For the missing coverage, as I said above, I tried but did not find any distribution that triggers |
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 #1869
The issue
Specifically for mixture models, in this code
Distributions.jl/src/mixtures/mixturemodel.jl
Lines 446 to 450 in da420cd
Let's call$F(x) = \text{cdf}(d, x)$ and $F_i(x) = \text{cdf}(\text{component}(d, i), x)$ , same $F^{-1}$ and $F_i^{-1}$ for quantile.
quantile_bisectrequires thatotherwise an error is thrown. Mathematically, in the code above, the condition is guaranteed. But if we take the definition of$q_\text{min}$ and $q_\text{max}$ , the condition becomes
And numerically, for some specific edge cases dealing with very small numbers, this condition is not satisfied. For example,
I found another example different than "almost identical" components, but still with the same issue:
I did not found any issues such that$p < F(q_\text{min})$ though. It's always $p > F(q_\text{max})$ . Maybe it is impossible with mixtures?
The fix
Because it seems specific to mixture models, we could simply make the interval wider in
quantile(d::UnivariateMixture{Continuous}, p::Real)by adding some small number tomax_qand subtracting some small number frommin_q. But I think it would be better to make thequantile_bisectfunction more robust, by allowing it to widen the interval if the condition is not satisfied. It does not impact the old case at all, and it would fix the issue for mixture models, and potentially for other / future distributions with similar issues.