Oddly asides... I was looking into doing some rudimentary filtering in assembler yesterday. Well, me not being the mathematician type, I called it "Rolling averages" or "Windowed means".
Take a value which you can read every time you are executed, then write it to a peripheral register to display and return.
Now that value is hard to read as it just jumps around all over the place. 32.4 29.2 24.5 38.2 ... to the human eye it's nearly meaningless updating every 0.5 seconds.
So what is the simpliest way to address this I wondered?
If I take the "running average", add the next value to it and divide the result by two, it's still an "average" right? Don't be mean about "mean" now!
A quick thought experiment makes you think it's not though.
10, 20, 30 avg 20
However,
10, 20 avg 15
15, 30 avg 22.5
Yet looking more closely 22.5 is a valid value for a "window size" or "set" of 2. (EDIT: I know it's not now... now I do) The value "20" is for a window of 3. Both are correct in there own way.
The thing is though. (15+30) / 2. The "15" is the output of the previous averaging. Therefore this is not a finite response "averaging function" at all, it's a decay function. A single datum pulse will result in an exponential decay response.
I'm sure there are correct mathematical terms, but it's just amazing how much of a can of worms TWO single ASM instructions can get you into.
Anyway. For it's purpose, to smooth out a "jumping" datum so it makes sense to a human and will allow them to spot trends.... for that I need to spend some memory and some iteration and use a proper rolling window and average it. Not with 2 values, but with a dozen maybe.
Other janks not becoming of someone who did any maths study.... If I don't display the value itself, but it's mid point between itself and it's previous, that will give me an intregal? Where it will approach the real value faster if its changing quickly, but slower if its not. But never reaching the actual value. "If the sales man travels half the distance to the destination each day, how long does it take?" (EDIT: It's the same thing as avg+current/2.)