Re: mean and stdev w/ errors [message #71033] |
Tue, 25 May 2010 13:00 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On May 25, 1:07 pm, Gray <grayliketheco...@gmail.com> wrote:
> Hi all,
>
> I have a set of observations and errors associated with them. I'd
> like to calculate the mean and standard deviation of this sample,
> taking the errors into account. Does anyone have a routine that does
> this? Thanks!
I don't have a routine to do this. But for Gaussian statistics, it's
pretty simple.
; VALUE - sample values
; SIGMA - sample uncertainties (gaussian statistics)
; AVG_VALUE - output weighted mean value
; AVG_SIGMA - output standard error of weighted mean
pro weighted_mean, value, sigma, avg_value, avg_sigma
wts = 1/sigma^2
totwts = total(wts)
avg_value = total(wts*value) / totwts
avg_sigma = 1/sqrt(totwts)
end
|
|
|