This is part 4 of my series on calculating percentiles on streaming data.
var sp = require("streaming-percentiles'); // epsilon is allowable error. As epsilon becomes smaller, the // accuracy of the approximations improves, but the class consumes // more memory. var epsilon = 0.1; var gk = new sp.GK(epsilon); for (var i = 0; i < 1000; ++i) gk.insert(Math.random()); var p50 = gk.quantile(0.5); // Approx. median var p95 = gk.quantile(0.95); // Approx. 95th percentile
You can find it here: