-
Notifications
You must be signed in to change notification settings - Fork 31
/
bucket_counts.js
117 lines (113 loc) · 1.13 KB
/
bucket_counts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const bucket_items_50 = [
0,
615,
205,
290,
180,
169,
132,
94,
82,
91,
79,
55,
43,
59,
61,
58,
44,
117,
115,
85,
73,
68,
92,
109,
105,
327,
244,
39,
10,
2,
0,
2,
1,
0,
0,
1,
]
const bucket_items_10 = [
0,
7567,
1512,
1095,
2417,
3104,
2367,
137,
19,
13,
1,
]
const size_counts = [
0,
5496,
24211,
7895,
899,
329,
258,
240,
232,
194,
204,
182,
158,
140,
146,
139,
134,
110,
104,
108,
81,
89,
81,
59,
77,
59,
60,
59,
58,
63,
40,
38,
38,
41,
40,
55,
36,
27,
29,
42,
27,
40,
34,
26,
25,
25,
22,
26,
28,
25,
614,
]
const mean = nums => {
const num = nums.reduce((a, b, idx) => a+b, 0)
const sum = nums.reduce((a, b, idx) => a+b*idx, 0)
console.log('sum', sum, num)
console.log('mean', sum / num)
}
mean(size_counts)
mean(bucket_items_50)
mean(bucket_items_10)