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
The problem occurs in the nice subroutine where the domain is erroneously niced to [0.93, 1.07]; the assumption is that the nice domain must subsume the original domain, but that’s not true with this input. That’s because:
The niced domain should be [0.9298, 1.07] instead. We probably need a threshold test instead of assuming that ceil and floor produce the desired result.
(That said, I’m curious where the 0.9299999999999999 is coming from? Because if we control that code, we should try to get it to generate 0.93 instead which would avoid this problem.)
This number is initially caused by a floating point error in this code I'm playing with:
constdata=[0,2, ...Array.from({length: 18},()=>1)];// Array(20)constlo=d3.quantile(data,0.05);consthi=d3.quantile(data,0.95);constdelta=(hi-lo)*0.2;constbins=d3.bin().thresholds(500).value((d)=>clamp(d,lo-delta,hi+delta))(data);returnbins.filter((d)=>d.length);// [Array(18), Array(1)] 🌶 there should be 20 totalfunctionclamp(x,lo,hi){returnx<lo ? lo : x>hi ? hi : x;}
(I've "fixed" my code by using 1/7 instead of 0.2…)
Activity
mbostock commentedon Mar 16, 2025
The problem occurs in the
nice
subroutine where the domain is erroneously niced to [0.93, 1.07]; the assumption is that the nice domain must subsume the original domain, but that’s not true with this input. That’s because:Also:
The niced domain should be [0.9298, 1.07] instead. We probably need a threshold test instead of assuming that ceil and floor produce the desired result.
mbostock commentedon Mar 16, 2025
(That said, I’m curious where the 0.9299999999999999 is coming from? Because if we control that code, we should try to get it to generate 0.93 instead which would avoid this problem.)
Fil commentedon Mar 16, 2025
This number is initially caused by a floating point error in this code I'm playing with:
(I've "fixed" my code by using 1/7 instead of 0.2…)