Bug 762

Summary: Correcting stderr formula in average.h
Product: ns-3 Reporter: TimoB <tbns>
Component: generalAssignee: Pavel Boyko <boyko>
Status: RESOLVED FIXED    
Severity: normal CC: faker.moatamri, ns-bugs, timo.bingmann
Priority: P2    
Version: pre-release   
Hardware: All   
OS: All   
Attachments: patch
new API version
average.h with unbiased variance estimate

Description TimoB 2009-12-03 02:44:03 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.
Comment 1 Pavel Boyko 2009-12-10 06:52:53 UTC
Created attachment 696 [details]
new API version
Comment 2 Pavel Boyko 2009-12-10 06:53:32 UTC
Timo, what about this version?
Comment 3 TimoB 2009-12-11 05:33:37 UTC
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
Comment 4 Pavel Boyko 2009-12-11 05:43:36 UTC
(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
Comment 5 TimoB 2009-12-11 06:29:10 UTC
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()).
Comment 6 Pavel Boyko 2009-12-11 07:34:01 UTC
Created attachment 697 [details]
average.h with unbiased variance estimate
Comment 7 Pavel Boyko 2009-12-11 07:34:25 UTC
(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?
Comment 8 TimoB 2009-12-11 15:59:41 UTC
Okay that goods now. Maybe add "unbiased" to doxygen comment for Stddev(),
but other than that. Good.
Timo
Comment 9 Pavel Boyko 2009-12-19 09:49:53 UTC
fixed in ecd61941c854