Weighted Average Operation/Function?
jjweimer
Function WeightedAverage(w,ew)
wave w, ew
variable av, su
duplicate/FREE w wtmp, ewtmp
ewtmp = 1/ew^2
wtmp = ewtmp*w
av = sum(wtmp)/sum(ewtmp)
su = sqrt(numpnts(w))/sqrt(sum(ewtmp))
print av, su
return 0
end
wave w, ew
variable av, su
duplicate/FREE w wtmp, ewtmp
ewtmp = 1/ew^2
wtmp = ewtmp*w
av = sum(wtmp)/sum(ewtmp)
su = sqrt(numpnts(w))/sqrt(sum(ewtmp))
print av, su
return 0
end
Does a function or operation already exist that does this?
Jeremy, I think the Wikipedia page may provide more of an answer for the weighted population variance.
http://en.wikipedia.org/wiki/Weighted_mean
December 29, 2009 at 07:05 pm - Permalink
Thanks. The page supports the method I am using. I wondered whether Igor has a built-in function or operation to calculate weighted averages and variance calculations directly.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
December 30, 2009 at 06:54 am - Permalink