0
$\begingroup$

I have some data on a cyclists distance traveled and hours it took.

    MILES  HOURS MPH    DAYS_AGO  WEIGHT
0   2      5     0.4    10        0.3175
1   5      10    0.5    4         0.3375
2   14     20    0.7    2         0.3450

I am trying to get an average of MPH for the cyclist.

The WEIGHT column in this table is using an exponential time decay to get the appropriate weight 0.99 ^ DAYS_AGO so samples further back in time have smaller weights.

The issue I am stuck on is this becomes a weighted average since the HOURS per row differ but then there is an additional weighting source which is the exponential time decay.

Would something as simple as sum(MILES * WEIGHTS) / sum(HOURS * WEIGHT) work for this?

$\endgroup$
9
  • $\begingroup$ Sorry but I don't get your question, what is the problem of the traditional sum(weight*MPH)/sum(weight) ? $\endgroup$ Commented Jun 4, 2022 at 3:26
  • $\begingroup$ @PrestonLui the MPH's of each row have different amount of hours $\endgroup$
    – radio23
    Commented Jun 4, 2022 at 3:27
  • $\begingroup$ 0.4 MPH in 5 hours (row 0) isn't the same as 0.7 MPH in 20 hours (row 2) $\endgroup$
    – radio23
    Commented Jun 4, 2022 at 3:29
  • $\begingroup$ There is not enough information to answer the question: exactly what kind of average do you want? In settings like this, the arithmetic mean of the speed is equivalent to the harmonic mean of its reciprocal (time taken per unit distance)--and both can be relevant, depending on the application. $\endgroup$
    – whuber
    Commented Jun 4, 2022 at 12:00
  • 1
    $\begingroup$ I would like the weighted arithmetic mean, which is sum(miles) / sum(hours) but I would like this to also be weighted by the WEIGHT column in this table which is an exponential time decay where it gives a higher weight to more recent observations @whuber $\endgroup$
    – radio23
    Commented Jun 4, 2022 at 19:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.