MCPcopy Create free account
hub / github.com/microsoft/SandDance / dotbin

Function dotbin

docs/app/js/sanddance-app.js:119190–119207  ·  view source on GitHub ↗
(array, step, smooth, f)

Source from the content-addressed store, hash-verified

119188// Based on Leland Wilkinson, Dot Plots, The American Statistician, 1999.
119189// https://www.cs.uic.edu/~wilkinson/Publications/dotplots.pdf
119190function dotbin(array, step, smooth, f) {
119191 f = f || ((_)=>_);
119192 const n = array.length, v = new Float64Array(n);
119193 let i = 0, j = 1, a = f(array[0]), b = a, w = a + step, x;
119194 for(; j < n; ++j){
119195 x = f(array[j]);
119196 if (x >= w) {
119197 b = (a + b) / 2;
119198 for(; i < j; ++i)v[i] = b;
119199 w = x + step;
119200 a = x;
119201 }
119202 b = x;
119203 }
119204 b = (a + b) / 2;
119205 for(; i < j; ++i)v[i] = b;
119206 return smooth ? smoothing(v, step + step / 4) : v;
119207} // perform smoothing to reduce variance
119208// swap points between "adjacent" stacks
119209// Wilkinson defines adjacent as within step/4 units
119210function smoothing(v, thresh) {

Callers

nothing calls this directly

Calls 2

fFunction · 0.70
smoothingFunction · 0.70

Tested by

no test coverage detected