Skip to content

Inconsistency between doc and code #30

@theclapp

Description

@theclapp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions