Skip to content

Instantly share code, notes, and snippets.

@unki2aut
unki2aut / bucketMedian.js
Created October 21, 2020 14:19
median of a continuous frequency distribution
const amount = 10000; // the smaller the amount, the more the bucket median is off
const data = generateValues(amount, 300);
console.log({
amount,
normalMedian: normalMedian(data.values),
bucketMedian: bucketMedian(data.buckets),
});
function normalMedian(arr) {