We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard deviation doesn't work well for EMA. It's better to use deviation by the same way as EMA is calculated.
my suggestion... var emaVariance = function(vector, options, callback) { // Single numeric argument defining the smoothing period if (typeof options === 'number') { options = { period: options, ratio: function(n) { return 2 / (n + 1); } }; } var variance = vector.slice(0, options.period).toVector().variance(), ratio = options.ratio(options.period), emaVariance = [variance].toVector(); emaVariance.divide(options.period / (options.period - 1)); for (var i = 0, len = vector.length - options.period; i < len; i++) { emaVariance.push( ratio * Math.pow(vector[i + options.period], 2) + (1 - ratio) * emaVariance[i] ); } return result(emaVariance, callback); }; var emaDev = function(vector, options, callback) { return result(_(emaVariance(vector, options)).map(function (v) { return Math.sqrt(v) }), callback); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Standard deviation doesn't work well for EMA. It's better to use deviation by the same way as EMA is calculated.
my suggestion...
var emaVariance = function(vector, options, callback) {
// Single numeric argument defining the smoothing period
if (typeof options === 'number') {
options = {
period: options,
ratio: function(n) { return 2 / (n + 1); }
};
}
var variance = vector.slice(0, options.period).toVector().variance(),
ratio = options.ratio(options.period),
emaVariance = [variance].toVector();
emaVariance.divide(options.period / (options.period - 1));
for (var i = 0, len = vector.length - options.period; i < len; i++) {
emaVariance.push(
ratio * Math.pow(vector[i + options.period], 2) + (1 - ratio) * emaVariance[i]
);
}
return result(emaVariance, callback);
};
var emaDev = function(vector, options, callback) {
return result(_(emaVariance(vector, options)).map(function (v) { return Math.sqrt(v) }), callback);
};
The text was updated successfully, but these errors were encountered: