percentil: refactor

This commit is contained in:
Alexander Zobnin
2017-10-16 15:25:02 +03:00
parent 872f1ac9c8
commit f53eac6f08
12 changed files with 65 additions and 9 deletions

View File

@@ -322,6 +322,11 @@ function expMovingAverage(datapoints, n) {
return ema;
}
function PERCENTIL(n, values) {
var sorted = _.sortBy(values);
return sorted[Math.floor(sorted.length * n / 100)];
}
function COUNT(values) {
return values.length;
}
@@ -482,7 +487,8 @@ const exportedFunctions = {
AVERAGE,
MIN,
MAX,
MEDIAN
MEDIAN,
PERCENTIL
};
export default exportedFunctions;