/ Published in: Python
Expand |
Embed | Plain Text
def weightedmean(x,w): num=sum([x[i]*w[i] for i in range(len(w))]) den=sum([w[i] for i in range(len(w))]) return num/den
You need to login to post a comment.
adkatrit on 02/11/11
1 person have marked this snippet as a favorite
def weightedmean(x,w): num=sum([x[i]*w[i] for i in range(len(w))]) den=sum([w[i] for i in range(len(w))]) return num/den
You need to login to post a comment.