Rolling Average

Has anyone done anything with trying to to calculate a rolling average?

Let's assume I have a list of numbers 1-100 (100 rows with each cell having a value 1-100 vertically for its respective row). How could you get a rolling average on the Nth row given a certain number of rows that you would like to look back? So if we have a lookback value of say 3, on row three, I think I would expect (3+2+1)/3. On the 50th row, I would expect (50 + 49 + 48)/3.

The above is simple and I could probably do something crude like ((n) + (n-1) + (n-3))/3. But this kind of only works when you have a clean sequence. And not for variable values that could represent money or something else.

Any ideas?

Best wishes

Hi Twitch,

the search function would have give a hint:

I built a little task as an example.
rolling-sum.morph (3.9 KB)
You see the result of your original example, when you disable the action and get a random result (no sequence) with enabled action:
image

Hope this helps.

Kind regards,

Jochen

Hi @Twitch,

If I understand your use case correctly, the new Sliding Aggregation action might be what you need. The attached screenshot shows an example of a sliding average with a window of 3.

3 Likes

Dismissed this new function. :+1:

Hi Jochen,

Thank you for taking the time to figure out a solution. My apologies, I did try searching the forum but I tried searched on "rolling average" and not rolling aggregate. And I didn't get any hits on my other searches so thought it was something that hadn't been discussed before.

Thanks again!

1 Like

This works beautifully. Thank you so much.

2 Likes