Problem 106. Weighted average
Solution Stats
Problem Comments
-
23 Comments
weighted mean should really be sum(x.*w)/sum(w), and not as defined in the problem.
I agree with the definition above. You need to define the sum of all the weights and not the number of weights.
As the others have said, the problem title is flat out wrong. What is required is simply not a weighted average in any standard form.
Come on Mathworks, delete this problem!
The test suits for this problem should have tests with different vector length.
There are "solutions" that just divide by 3.
I think the program title is wrong as in weighted average the denominator should contain sum of all weights
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!
this is not really the weighted average, because of 10 15 and 20 the average can't never be 33.333 here is a bug
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.
Good problem
kinda misleading, but i get the gist of it
good question
yay
tricky
easy
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
very good
nice
why leading size is always 7? and how :(
On a weighted average we should divide the weighted values by the sum of the weights and not by the number of terms. https://en.wikipedia.org/wiki/Weighted_arithmetic_mean
@Mehmed Saad: some of the many cheating solutions have been deleted.
This problem definitely needs to be fixed to use the correct weighted average formula.
Solution Comments
Show commentsProblem Recent Solvers6659
Suggested Problems
-
1935 Solvers
-
462 Solvers
-
Set the array elements whose value is 13 to 0
1369 Solvers
-
542 Solvers
-
Create a two dimensional zero matrix
489 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!