expMovingAvg: use window size as param

This commit is contained in:
Alexander Zobnin
2017-07-04 10:16:41 +03:00
parent 0b8cb0b23c
commit e0466ea780
4 changed files with 13 additions and 1 deletions

View File

@@ -253,6 +253,10 @@ System.register(['lodash', './utils'], function (_export, _context) {
}
function expMovingAverage(datapoints, a) {
// Calculate a from window size
if (a > 1) {
a = 2 / (a + 1);
}
var ema = [datapoints[0]];
var ema_prev = datapoints[0][POINT_VALUE];
var ema_cur = void 0;

File diff suppressed because one or more lines are too long

View File

@@ -278,6 +278,10 @@ function simpleMovingAverage(datapoints, n) {
}
function expMovingAverage(datapoints, a) {
// Calculate a from window size
if (a > 1) {
a = 2 / (a + 1);
}
var ema = [datapoints[0]];
var ema_prev = datapoints[0][POINT_VALUE];
var ema_cur = void 0;