Problem 106. Weighted average
Given two lists of numbers, determine the weighted average as follows
Example
[1 2 3] and [10 15 20]
should result in
33.3333 (1*10 + 2*15 + 3*20)/3
Solution Stats
Problem Comments
-
23 Comments
Show
20 older comments
Rafael S.T. Vieira
on 19 Jul 2020
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
goc3
on 28 Sep 2020
@Mehmed Saad: some of the many cheating solutions have been deleted.
Benjamin Farris
on 2 Nov 2020
This problem definitely needs to be fixed to use the correct weighted average formula.
Solution Comments
Show commentsProblem Recent Solvers6675
Suggested Problems
-
5970 Solvers
-
343 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2496 Solvers
-
Find the sum of the elements in the "second" diagonal
1159 Solvers
-
388 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!