Skip to content
New issue

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

Inconsistency between doc and code #30

Open
theclapp opened this issue Nov 2, 2022 · 0 comments
Open

Inconsistency between doc and code #30

theclapp opened this issue Nov 2, 2022 · 0 comments

Comments

@theclapp
Copy link

theclapp commented Nov 2, 2022

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:

ewma/ewma.go

Lines 8 to 14 in 487e8c9

// By default, we average over a one-minute period, which means the average
// age of the metrics in the period is 30 seconds.
AVG_METRIC_AGE float64 = 30.0
// The formula for computing the decay factor from the average age comes
// from "Production and Operations Analysis" by Steven Nahmias.
DECAY float64 = 2 / (float64(AVG_METRIC_AGE) + 1)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant