ewma icon indicating copy to clipboard operation
ewma copied to clipboard

Inconsistency between doc and code

Open theclapp opened this issue 3 years ago • 0 comments

The readme says

So, for example, if you have a time-series with samples once per second, and you want to get the moving average over the previous minute, you should use an alpha of .032786885. This, by the way, is the constant alpha used for this repository's SimpleEWMA.

That alpha corresponds to N = 60, 2/(N+1) = 2/61 = .032786885.

The actual code uses 2/31: https://github.com/VividCortex/ewma/blob/487e8c9fe1e218b64696ee0219903a3a40d0dc2b/ewma.go#L8-L14

The readme may be using N with two different meanings in the section on "Choosing Alpha", but I don't think so. I think 2/31 is incorrect.

The comment in the code is also inconsistent with the readme. The readme talks about "N samples", whereas the code talks about "average age".

It's certainly possible I'm misunderstanding something.

theclapp avatar Nov 02 '22 17:11 theclapp