Menu

#632 Moving average operator

Babbage
wont-fix
nobody
None
2Critical
2024-08-23
2024-08-22
Steve Keen
No

I was trying to reproduce the trick you showed me to emulate a 3 year moving average (I'll attach the successful model in the next message) and it failed at the first step, since the trick which worked with stock market data--create a vector of 1s and then sum that so that it goes 1 2 3 3 3 3 ... failed: I just get 1 2 3 4 5 6 7 ...

A diagnosis of why this worked for one file (in the next entry) and didn't in this one would be useful. But the best move would be to create a moving sum operator, which can then be divided by a scalar to produce a moving average.

Moving sums/averages are faily common operations, especially for people in finance (as in the next file) so it would be good to just have an operator, rather than a workaround which, for some reason, didn't work in this attempt.

1 Attachments

Discussion

  • Steve Keen

    Steve Keen - 2024-08-22

    The successful workaround file.

     
  • High Performance Coder

    You need to specify a window size of 3 to get 1 2 3 3 3 3

     
  • Steve Keen

    Steve Keen - 2024-08-22

    I did that. See image and RVL file.

     
    • High Performance Coder

      The axis is called Year, not Date.

       
  • Steve Keen

    Steve Keen - 2024-08-22

    Strange! I added a new running sum, and it worked with that. But it's still not working with the older one.

     
  • Steve Keen

    Steve Keen - 2024-08-22

    Here's another comparison. The original operator doesn't work, with the same settings on which the new one does.

     
  • Steve Keen

    Steve Keen - 2024-08-22

    Replace the old running sum operator with the new one and everything is fine.

     
  • Steve Keen

    Steve Keen - 2024-08-22

    Finally got the intended result. I hope I've uncovered something buggy in the code in the process.

    The exercise has emphasised the desirability of a running sum and a running average operator. In terms if icons, maybe indicate them with arrows <--> above the current cumulative sum and average operators?

     
  • High Performance Coder

    It looks to me like you copied a running sum operator that was summing along "Date" into a new situation that needs to sum along "Year". It looks to me like everything is running as it should.

     
  • High Performance Coder

    • status: open --> wont-fix
     
  • High Performance Coder

    Even if there was a moving average operator, you'll still need to get axis and window arguments right.

    I'm going to add a feature request for the operators to name their arguments. In this case "Argument" could be called "Window", and appear as such in the dialog. Delta operators could call their argument "delta".

     

Log in to post a comment.