I have a wave of data with a wave of corresponding standard uncertainties. I want to compute the weighted average and weighted standard uncertainty from the data and uncertainties waves. For the average, this basically involves dividing each data value by the square of its uncertainty (its variance) as a weighting, then adding and renormalizing. A corresponding function determines the weighted standard uncertainty of the set. An example code would be ...
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
return0end
Does a function or operation already exist that does this?
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
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