Initialised EWM
See original GitHub issueCurrently, with an exponential weighted moving window, there are two options, adjusted, or non-adjusted. The first one results in excessively high variance at the beginning of the series, the second results in an artificially low mean. Another alternative is to intialise the series with a scalar value - most obviously the mean. Here is a comparison of how these three variations look:
This is from a hacky iterative implementation I just wrote as a proof of concept, but it shouldn’t be hard to write an implementation that’s just as efficient as the adjusting version. If this seems useful, I’m happy to make a PR.
What would be the best API design? Perhaps just add an initialise=None
that accepts floats, and overrides the adjust=
argument if it is set?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Related SO answer
I think an
initialize=
keyword would be a reasonable addition, if just for convenience, though I definitely would not use the long term mean as a default. It may make sense in some cases, but using future data in the estimate is pretty antithetical to a “moving average”, in general.Yeah, maybe, although I’m not sure of the best way to do it efficiently this way - it requires the creation of a new DataFrame.
Also, I think using the long-term mean is a pretty sane default behaviour - it’s still data-driven (assuming some level of stationarity), and it produces a much more realistic result than either of the current options.