1

How to find the weighted average x? From graphing x(y) it looks to be around x=0.45?

y = [0.1 0.1 0.2 0.5 0.4 0.2]
x = [0.1 0.2 0.3 0.4 0.5 0.6]

One way to perhaps compute it would to find x where the area under the curve y(x) is half of the area under the whole curve. But how to write that in matlab?

Dwadelfri
  • 454
  • 1
  • 4
  • 15

1 Answers1

2

Assuming you intend y to be the weights, and you want to compute the weighted average of x, then the weighted average is simply

sum(x.*y) / sum(y)
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120