If you/ve done signal processing theory it’s obvious, otherwise get ready for some math!
Put simply: we start with some location, the current one.
A new point comes in, and we find the ‘error’ – meaning, the x/y distance from where we are to where the new point is.
Then, we move our point towards the input by some percentage of the error. This can be anywhere from 0 to 1, with values like 0.1 or 0.8 being the most useful.
Then you just apply this, one point at a time. really simple, but it’ll wobble as much as the weighted average will. So I apply a deadzone after that. Play around with it and see what works for you. I’ll probably post my code this weekend.