Bugzilla – Bug 762
Correcting stderr formula in average.h
Last modified: 2009-12-19 09:49:53 UTC
Created attachment 691 [details] patch Turned out to be incorrect after staring alternately at the code and at my math book for 15min. Also added margin of error functions.
Created attachment 696 [details] new API version
Timo, what about this version?
Generally fine by me. Some small points: Changing Err() -> Stddev() is good, but you also have to fix some line in the udp-helper. Why do you Size() - 1? I believe m_size is the number of samples, and its plain sqrt(n) in the formula. Timo
(In reply to comment #3) > Generally fine by me. Some small points: > > Changing Err() -> Stddev() is good, but you also have to fix some line in the > udp-helper. I can't find udp-helper, but sure I will update all API usage instances. > Why do you Size() - 1? I believe m_size is the number of samples, and its plain > sqrt(n) in the formula. That's because you can't estimate the error of the mean from single sample (count = 1 => error = \infty). Take a look at http://mathworld.wolfram.com/SampleVariance.html
Okay, so we need to specify whether it is a biased or unbiased estimate. But then the current sqrt() in the margin formula uses a biased estimate of the variance (from Var()).
Created attachment 697 [details] average.h with unbiased variance estimate
(In reply to comment #5) > Okay, so we need to specify whether it is a biased or unbiased estimate. > > But then the current sqrt() in the margin formula uses a biased estimate of the > variance (from Var()). You are right. What about this version?
Okay that goods now. Maybe add "unbiased" to doxygen comment for Stddev(), but other than that. Good. Timo
fixed in ecd61941c854