Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function (key, values, rereduce) {
- // value -> [count, min, max, mean]
- var i = 0
- , l = values.length
- , min = values[i][2] // set min to the first max
- , max = 0
- , mean = 0
- , count = 0
- ;
- for (; i < l; i++) {
- min = Math.min(min, values[i][1]);
- max = Math.max(max, values[i][2]);
- mean = ((mean * count) + (values[i][3] * values[i][0])) / (count + values[i][0]);
- count = count + values[i][0];
- }
- return [min, max, mean];
- }
Add Comment
Please, Sign In to add comment