You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
medianIndex/quantileIndex doesn’t handle missing data #275
I don’t think this is the intended behavior, even if we were trying to chose the “lower” element in the case where the array length is even. I expect it to return the index of the median value instead.
Although, we are still returning the last index of equivalent values (it appears), and I think it would be preferable to return the first. But, any of those would be correct as long as we document it.
Activity
mbostock commentedon May 30, 2023
It also seems to returning the last index if there are multiple elements with the median value?
mbostock commentedon May 30, 2023
Ah ha. The problem is that we’re dropping undefined values in the initial filter:
d3-array/src/quantile.js
Line 36 in c62f825
This means that the indexes are indexes into the filtered array, and hence are wrong. If we pre-filter the data the correct result is returned:
Although, we are still returning the last index of equivalent values (it appears), and I think it would be preferable to return the first. But, any of those would be correct as long as we document it.
[-]medianIndex/quantileIndex is off by one[/-][+]medianIndex/quantileIndex is wrong[/+][-]medianIndex/quantileIndex is wrong[/-][+]medianIndex/quantileIndex doesn’t handle missing data[/+]Fil commentedon May 30, 2023
ouch!