correct 1, 5, 15 minute smoothing factors #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MeterMetric's EWMA function is correct, presuming FACTOR means α, the smoothing factor. However the factors themselves are miscalculated.
The one minute factor is actually 1-α, aka the EXP_R. Five minute and 15 minute factors are calculated in the right direction but only incidentally. Had they been formulated the same way as the one minute EXP_R, i.e. exp(-5/60/5) and exp(-5/60/15), they would be damping even less than the one minute factor. Also, though you can approximate the 5 and 15 minute alphas by dividing the 1 minute alpha, the result is off by a couple percent.
Attached patch to fix the factors. You may also want to rename FACTOR to ALPHA. Note that this dramatically changes the damping effect [the curve is approximately 11x slower]; users on the new code will see quite different behavior for the same input.
The kernel load average EWMA code stores 1, 5, 15 minute 'factors' as hard coded fixed point 11 bit EXP_Rs instead of alphas for the sake of speed and size. The load average macro itself is written in terms of EXP_R instead of alpha [and is the basis of my initial suggestion on twitter]. Perhaps this is where the error originated.
Hopefully I'm not way off in left field here, and thanks for the great project.