1

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
radio23
  • 11
  • What is wrong with taking the (weighted) average of any quantity that varies? Is that variation not the whole rason to take an average? – Kurt G. Jun 03 '22 at 02:08
  • Do you mean to take the weighted average of MILES and the weighted average of HOURS to get the final weighted average of MPH as WEIGHTED_MILES / WEIGHTED_HOURS – radio23 Jun 03 '22 at 02:11
  • The key is to use the relative times spent at various speeds as the weights, rather than the relative distances traveled. – user2661923 Jun 03 '22 at 02:16
  • The weighted average of MPH is commonly understood as the weighted average of MPH. If you calculate something else you should let your readers know clearly. – Kurt G. Jun 03 '22 at 02:17
  • The weights in my table are calculated using an exponential time decay, so 0.99 ^ DAYS_AGO I understand how to get the simple weighted average of sum(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
  • My point is that if you have (for example) $4$ trips of distances $d_1, d_2, d_3, d_4$, and speeds $s_1, s_2, s_3, s_4$ and $4$ durations $t_1, t_2, t_3, t_4$ and you wish to compute the average speed of the $4$ trips combined, there is only one way to do it. You have to compute a weighted average of $s_1, s_2, s_3, s_4$ using the relative weights represented by $t_1, t_2, t_3, t_4$. The way that I read your posting this is your goal. If it is your goal, you have no choice. ...see next comment – user2661923 Jun 03 '22 at 02:25
  • If this is not your goal, you need to edit your posting to very carefully provide as detailed an explanation as possible, as clearly as possible (directly in your posting, not the comments) as to what your actual goal is. – user2661923 Jun 03 '22 at 02:26
  • +1 : to your posting; nice editing. However, now you have an issue that only you can resolve. Imagine that you have to choose among several restaurants for a dinner, and the two factors to consider are relative price and expected relative quality of the meal. Only you can decide what relative weights to give of price vs quality. ...see next comment – user2661923 Jun 03 '22 at 02:36
  • You are apparently in the same position, where you are attaching importance to independent factors: how recent the trip was, and the duration of the trip. This is very similar to the Olympics (e.g. figure skating) where each individual judges evaluates various factors and gives his individual overall score. Only you can decide how to arbitrarily balance duration of trip versus how recent the trip was. – user2661923 Jun 03 '22 at 02:40

0 Answers0