mimir icon indicating copy to clipboard operation
mimir copied to clipboard

Add warmup counter to EWMA rate

Open slimjim777 opened this issue 1 year ago • 3 comments
trafficstars

What this PR does

Adds a warm-up period to the EWMA rate so that the rate for the first N samples is returned as 0. The approach mirrors the approach in VividCortex, although there the recommendation is to initialize the moving rate as the mean of the first 60 samples.

Which issue(s) this PR fixes or relates to

Fixes #5443

Checklist

  • [X] Tests updated.
  • [ ] Documentation added.
  • [ ] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [ ] about-versioning.md updated with experimental features.

slimjim777 avatar Oct 03 '24 19:10 slimjim777

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 03 '24 19:10 CLAassistant

@jhalterman I took a shot at #5443 and the implementation is in between the VividCortex approach (with a counter) and the current approach with using the sliding window time. This returns 0 during the first 9 ticks, whereas the sliding window time does that for the first 60s.

I amended the existing test for math.EWMARate to expect 0 for the first 9 samples, but I suspect that there other tests that will fail as a result of this change.

slimjim777 avatar Oct 03 '24 19:10 slimjim777

Amended the warm-up sample count to be 60 so it's aligned with the sliding window time of 60s.

slimjim777 avatar Oct 12 '24 19:10 slimjim777

Hi @slimjim777 Thanks for the PR and apologies for the delay!

My main question is, can we make the warmup size configurable? We could create an EWMA with warmup via something like NewEWMARateWithWarmup.

jhalterman avatar Feb 27 '25 03:02 jhalterman

My main question is, can we make the warmup size configurable? We could create an EWMA with warmup via something like NewEWMARateWithWarmup.

I’ll add that

slimjim777 avatar Feb 27 '25 08:02 slimjim777

Hi @slimjim777 Thanks for the PR and apologies for the delay!

My main question is, can we make the warmup size configurable? We could create an EWMA with warmup via something like NewEWMARateWithWarmup.

I've added a NewEWMARateWithWarmup method.

(It could have been done with adding the functional options approach or a builder pattern, but I kept it as a separate constructor)

slimjim777 avatar Mar 02 '25 15:03 slimjim777

Thank you for your contribution. This pull request has been marked as stale because it has had no activity in the last 150 days. It will be closed in 30 days if there is no further activity. If you need more time, you can add a comment to the PR.

github-actions[bot] avatar Aug 05 '25 02:08 github-actions[bot]

This pull request has been closed because it has been stale for 30 days with no activity. Feel free to reopen if you want to continue working on this.

github-actions[bot] avatar Sep 05 '25 02:09 github-actions[bot]