mir.random.discrete - fix for zero probilities#236
Merged
9il merged 2 commits intolibmir:masterfrom Jun 26, 2016
Merged
Conversation
| // sample from the discrete distribution | ||
| auto obs = new uint[cdPoints.length]; | ||
| foreach (i; 0..1000) | ||
| foreach (i; 0..10_000) |
Member
Author
There was a problem hiding this comment.
the split looks too random with 1000
Current coverage is 96.53%@@ master #236 diff @@
==========================================
Files 19 19
Lines 3253 3262 +9
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 3140 3149 +9
Misses 113 113
Partials 0 0
|
source/mir/random/discrete.d
Outdated
| unittest | ||
| { | ||
| import std.random : Random; | ||
| auto gen = Random(42); |
Member
There was a problem hiding this comment.
OK, but don not use Random alias then. Use exact name instead.
There was a problem hiding this comment.
Agree, it's better to specify an exact generator just in case someone later adds some tests that depend on the pseudo-random sequence.
Member
Author
Ok - done ;-) |
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.
(in reference to #235)
As @WebDrake pointed out
Discretedoesn't handle zero probabilities well.Also as we don't use chi-squared tests, but I think it's at least helpful to insert the assert's for the currently tested distributions.
With zero probs we can't use
lowerBound, because it will it will not stop on the first element, but go to all equal element. Hence we either count the first category twice or the third one.Here's an example of what's going on: