Weighted Average Operation/Function?

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

    return 0


Does a function or operation already exist that does this?
[quote=andyfaff]Link to weighted mean and variance. ..... http://en.wikipedia.org/wiki/Weighted_mean[/quote]

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