reset histograms to min of zero on the fly #1164
Merged
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.
I created a fix that shifted a histogram if we obtained a zero-valued result after construction of a histogram to allow the Histogram Min to be 0, not just the sample min. The fix requires us to shift the histogram up to add the required number of bins to reach zero, and put the leftward most edge of the histogram right at 0. This means that pre-shift bins and post-shift bins will partially overlap, and those partials need to be allocated out correctly based upon the fraction of the observations in a pre-shift bin that overlaps with the post-shift bin, where the fraction is determined with the assumption of a uniformly distributed bin. I think the majority of the histogram math works that way.
This fix is only reached if the min is 0. If the min goes below 0, so will the histogram.
This fix produces a really nice result. Prior to the fix, the histograms gave us really wonky left tails. See for example:
After the fix, we have a logical left tail:
A unit test is included to demonstrate that the added logic works as expected.