I have some data on a cyclists distance traveled and hours it took.
I want to get a weighted average of MPH, where more recent samples have a higher weight. The weights in the table use an exponential time decay to get the appropriate weight 0.99 ^ DAYS_AGO.
For example row 2 happened 2 days ago so I would like the MPH from row 2 to have a higher weight than the MPH from row 0. The issue I am stuck on is this becomes a weighted average of a weighted average since the simple weighted average would be sum(MILES) / sum(HOURS) but then I also want to add my time decay weighting to this.
MILES HOURS MPH DAYS_AGO WEIGHT
0 2 5 0.4 10 0.317
1 5 10 0.5 4 0.337
2 14 20 0.7 2 0.344
MILESand the weighted average ofHOURSto get the final weighted average ofMPHasWEIGHTED_MILES/WEIGHTED_HOURS– radio23 Jun 03 '22 at 02:110.99 ^ DAYS_AGOI understand how to get the simple weighted average ofsum(MILES) / sum(HOURS)but I also want to use the time decay to weigh more recent samples more so it becomes kind of like a weighted average of a weighted average, unless I am misunderstanding your point @user2661923 – radio23 Jun 03 '22 at 02:20