Hahaha, who wrote this problem? This is not a weighted average! Just look at the example provided: the weighted average of 1, 2 and 3 is 33.3333, hahahahaha!
Yes. The description is completely wrong. To start with, a weighted average should have the property that
weighted_average(x,w) == weighted_average(x,k*w)
So a simple re-scaling of the weights should not impact the result.
Is it possible to remove this problem or at least change the problem name so it does not say "weighted average". As others have pointed out, the definition, via example, is inaccurate.
An average, weighted or otherwise, will not be greater than the largest number in the set (which is the case here).
In case you actually want to try a weighted average problem, you can check out the one here
https://www.mathworks.com/matlabcentral/cody/problems/44156-weighted-average
This is a seriously flawed problem. I'm sorry, but it is. It uses an incorrect definition of a weighted average. As such, students might solve this problem, then try to use that same expression in code for some future job. A correct solution might better be:
y = x*w'/sum(w);
Easy, but not the weighted average. Even assuming that the first vector contains the weighting factors (for example the sizes of different sample groups) and the second vector contains the means of the sample groups, than the divisor has to be the sum of the weighting factors instead of the number.
20 players like this problem
20 players like this problem