// Dot density binning for dot plot construction. // Based on Leland Wilkinson, Dot Plots, The American Statistician, 1999. // https://www.cs.uic.edu/~wilkinson/Publications/dotplots.pdf export default function(array, step, smooth, f) { f = f || (_ => _); let i = 0, j = 1, n = array.length, v = new Float64Array(n), a = f(array[0]), b = a, w = a + step, x; for (; j= w) { b = (a + b) / 2; for (; i> 1); while (d < b) v[d++] = v[b]; while (d > b) v[d--] = v[a]; } // update left stack indices a = b; b = c; } return v; }