
Weighted Average and its Uncertainty

ChrLie
// after e.g. J.R. Taylor 1997, Introduction to error analysis, 2nd Ed., University Science Books, p175 // input waves MUST NOT contain NaNs or INFs function/WAVE WeightedAvg(data, error) wave data, error // define weight MatrixOP/O/FREE w = rec(magSqr(error)) // weighted average MatrixOP/O/FREE avg = sum(w * data) * rec(sum(w)) // uncertainty MatrixOP/O/FREE sigma = rec(sqrt(sum(w))) // Combine results into 2D wave, 1st col = wAvg, 2nd col = error Concatenate/O {avg,sigma}, W_wAvg return W_wAvg end

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More