I'm trying to get the weighted average of CpM (Cost per Mile) for the dataset below:
I'm calculating the average by:
1st approach: Average CpM = sum(TotalCost / Miles) / count = (2 + 2.85 + 3.1 + 2.9) / 4 = $2.715
However, I've seen a colleague calculate the weighted average CpM the following way:
2nd approach: Average CpM = sum(TotalCost) / sum(Miles) = (100 + 200 + 310 + 290) / (50 + 70 + 100 + 100) = $2.81
When we introduce a new outlier that has extremely high CpM to the dataset, the 1st approach tends to shoot up along with the outlier, while the 2nd is more robust to the outlier:
1st approach: Average CpM = sum(TotalCost / Miles) / count = (2 + 2.85 + 3.1 + 2.9 + 10) / 5 = $5.21
2nd approach: Average CpM = sum(TotalCost) / sum(Miles) = (100 + 200 + 310 + 290 + 100) / (50 + 70 + 100 + 100 + 10) = $3.03
I'm not sure if the 2nd approach of calculating Average CpM is a valid approach, and if not, what this formula means and what it's getting at. I also wonder if there are any other ways to calculate the weighted arithmetic mean.