Rolling average and standard deviation.....
-
I have a number of variables on a node that I would like to calculate a running average for and one or two that I would like to calculate standard deviation for.
With limited memory on a pro mini I wonder if anyone has already done this or has any ideas on the best way to approach it?
-
I have a number of variables on a node that I would like to calculate a running average for and one or two that I would like to calculate standard deviation for.
With limited memory on a pro mini I wonder if anyone has already done this or has any ideas on the best way to approach it?
@skywatch I usually use an exponential moving average (https://en.wikipedia.org/wiki/Moving_average) as it doesn't require keeping a sliding window of the past x values.
The idea is simple: new values are averaged over previous values with low weight.Eg
avg = (avg*(weight-1) + new) / weightweight is just a factor (as would the size of your window be). Large weight causes slow response to changes. If working with integer types pick a power of 2 for the weight, so the compiler optimizes the division to a simple bitshift operation instead of a real division.
-
@skywatch I usually use an exponential moving average (https://en.wikipedia.org/wiki/Moving_average) as it doesn't require keeping a sliding window of the past x values.
The idea is simple: new values are averaged over previous values with low weight.Eg
avg = (avg*(weight-1) + new) / weightweight is just a factor (as would the size of your window be). Large weight causes slow response to changes. If working with integer types pick a power of 2 for the weight, so the compiler optimizes the division to a simple bitshift operation instead of a real division.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login