probability or statistics – Mean age of people


values = {14, 15, 16, 22, 24, 25};
weights = {1, 1, 3, 2, 2, 5};

You can also use WeightedData:

Mean @ WeightedData[values, weights]
21

This also works with symbolic input:

values = Array[Subscript[x, #] &, 5];
weights = Array[Subscript[w, #] &, 5];

Mean @ WeightedData[values, weights] 

enter image description here

TeXForm @ %

$$frac{w_1 x_1+w_2 x_2+w_3 x_3+w_4 x_4+w_5 x_5}{w_1+w_2+w_3+w_4+w_5}$$