Skip to content

Instantly share code, notes, and snippets.

@1wheel
Last active Sep 2, 2015
Embed
What would you like to do?
Head Tails Breaks
function headTails(a, n){
var breaks = []
while(a.length){
var avg = mean(a)
breaks.push(avg)
a = a.filter(function(d){ return d > avg })
}
return breaks
}
function mean(a){
var total = a.reduce(function(p, v){ return p + v}, 0)
return total/a.length
}
a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 4, 10, 100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment