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

@@ -305,6 +305,11 @@ System.register(['lodash', './utils'], function (_export, _context) {
return ema;
}
function PERCENTIL(n, values) {
var sorted = _.sortBy(values);
return sorted[Math.floor(sorted.length * n / 100)];
}
function COUNT(values) {
return values.length;
}
@@ -474,7 +479,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
AVERAGE: AVERAGE,
MIN: MIN,
MAX: MAX,
MEDIAN: MEDIAN
MEDIAN: MEDIAN,
PERCENTIL: PERCENTIL
};
_export('default', exportedFunctions);