# Weighted average of weigthed data

Consider the following figure where we want to compute the average value on the y-axis. The y-axis is a rate, e.g Km/h.

For that we can use weighted average and do something like this

      (9*35.2) + (41*13) + (24.6*112) + (43.3*5.6)
----------------------------------------------------   =  23.2
(35.2 + 13 + 112 + 5.6)


Now, consider that each rectangle has a weight. That means, the weight vector associated with (K1,K2,K3,K4) is (0.21,0.07,0.67,0.035).

The question is, how can I get the average value with respect to the weights associated with each part? I would like to call it, double weighted average (!)

$$x_i y_i$$ is a size of the rectangle $$K_i$$, just calculate weighted average of those.

• Alright. One more thing. If the x-axis is time and the y-axis is a rate (per second), then I guess, the method is no accurate. I think for that, I have to use the weight vector with y-axis values and do a weighted harmonic mean, while using the weight vector with x-axis and do a weighted arithmetic mean. Is that right? – mahmood Apr 18 at 14:55
• @mahmood correct, you cannot multiply arbitrary numbers and expect a meaningful result. This will work for some data and for some not. – Tim Apr 18 at 16:53

It depends on the unit your weights are associated with. From what I can understand from the question, your weight vector may be associated in two ways:

1. Weights are associated with y-axis (i.e. rate):

In this case you need to multiply the individual weights with the x-length of your individual rectangles, and your average becomes

      (9*35.2*0.21) + (41*13*0.07) + (24.6*112*0.67) + (43.3*5.6*0.035)
--------------------------------------------------------------------------
(35.2*0.21 + 13*0.07 + 112*0.67 + 5.6*0.035)


This is because no matter how many layers of weights you want to apply, they have a multiplicative effect.

1. Weights are associated with rectangles (i.e. their areas):

Here your intention would be to calculate weighted average area of the rectangles (e.g. distance in a speed-time setting), and your average becomes

      (9*35.2*0.21) + (41*13*0.07) + (24.6*112*0.67) + (43.3*5.6*0.035)
--------------------------------------------------------------------------
(0.21 + 0.07 + 0.67 + 0.035)


Basically, the length of x-axis is no more acting as a weight in this case and has been removed from the denominator.