statistics
statistics copied to clipboard
Optimize Statistics.Quantile.weightedAvg/quantile
To calculate k-th q-quantile weightedAvg sorts approximately k/q smallest elements of an array. When k/q > 0.5 it's not optimal. We only need to sort upper 1-k/q elements in this case.