[histogram] squash end-inclusive histogram bins #172
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.
🐛 Bug Fix
This PR updates the computation for numeric bins in
@data-ui/histogram
to squash the last two bins together when the thresholds of the last bin are equal to the upper threshold of the second to last bin. Without doing this the results can be quite confusing as pointed out by someSuperset
users.example, given the following raw data
[0, 0, 1, 2, 3, 9, 9, 10, 10, 10]
(note10
is the max value) andbinCount=10
We get the following
11 bins
or with
binCount=20
(and21
resultant bins 🤔 )This issue explains this behavior
Specifically this clarifys that
n+1
bins, notn
x0 == x1 == 10
, equal to the upper bound of the second to last bin (x0 = 9
andx1 = 10
).After updating with this squashing, we get more intuitive results
cc @kristw @conglei