File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -129,3 +129,40 @@ func PutFast(f *Fast) {
129
129
}
130
130
131
131
var fastPool sync.Pool
132
+
133
+ func Quantile (fs []* Fast , phi float64 ) float64 {
134
+ return combine (fs ).quantile (phi )
135
+ }
136
+
137
+ func Quantiles (fs []* Fast , dst , phis []float64 ) []float64 {
138
+ t := combine (fs )
139
+ for _ , phi := range phis {
140
+ q := t .quantile (phi )
141
+ dst = append (dst , q )
142
+ }
143
+ return dst
144
+ }
145
+
146
+ func combine (fs []* Fast ) Fast {
147
+ n := 0
148
+ for _ , f := range fs {
149
+ n += len (f .a )
150
+ }
151
+
152
+ var t Fast
153
+ t .Reset ()
154
+ t .tmp = make ([]float64 , 0 , n )
155
+
156
+ for _ , f := range fs {
157
+ t .tmp = append (t .tmp , f .a ... )
158
+ if t .max < f .max {
159
+ t .max = f .max
160
+ }
161
+ if t .min > f .min {
162
+ t .min = f .min
163
+ }
164
+ }
165
+ sort .Float64s (t .tmp )
166
+
167
+ return t
168
+ }
You can’t perform that action at this time.
0 commit comments