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

add EWMA moving average option to ThroughputHistory, default remains sliding window #2094

Merged
merged 7 commits into from
Aug 18, 2017

Conversation

spiterikevin
Copy link
Contributor

No description provided.


function updateEwmaEstimate(ewmaObj, value, weight, halfLife) {
const fastAlpha = Math.pow(0.5, weight / halfLife.fast);
ewmaObj.fastEstimate = (1 - fastAlpha) * value + fastAlpha * ewmaObj.fastEstimate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So at startup, ewmaObj.fastEstimate is 0. So this is underestimating the EWMA at the beginning,(and as time rolls on, the 0 is weighted to almost nothing). Instead, the very first EWMA value should be just the first measurement. So, maybe we should be doing something like: set ewmaObj.fastEstimate to undefined, when the first measurement comes in, set ewmaObj.fastEstimate to that value, then carry on calculating the EWMA as before for future measurements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was compensating for startup in getAverageEwma() by doing fastEstimate = ewmaObj.fastEstimate / (1 - Math.pow(0.5, ewmaObj.totalWeight / halfLife.fast)). That also has the benefit of not giving the first measurement more weight than the next few measurements during startup. But I need to at least put some clear documentation here because the startup compensation code is rather hidden.

@dsparacio dsparacio merged commit 52fdec9 into Dash-Industry-Forum:development Aug 18, 2017
@spiterikevin spiterikevin deleted the ewma branch August 18, 2017 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants