Closed shaojl7 closed 7 years ago
The result you're seeing is below the machine precision, so it is numerically indistinguishable from 0. You have floating point numbers in your series, so you're doing floating point math, not integer math.
.Machine$double.eps
# [1] 2.220446e-16
see: What Every Computer Scientist Should Know About Floating Point Numbers
Also see the Kahan summation algorithm, which will be used in future versions of rolling window functions that will be in xts.
Hi Joshua
Thanks for the TTR package, it is quite helpful!
However, while calculating the moving average using SMA, I noticed some unexpected behavior
I am expecting the rolling average of 0s to be 0 as well, however, it returns a negative number
-2.602085214e-19
instead.My session info