Bug 762 - Correcting stderr formula in average.h
Correcting stderr formula in average.h
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: general
pre-release
All All
: P2 normal
Assigned To: Pavel Boyko
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-12-03 02:44 UTC by TimoB
Modified: 2009-12-19 09:49 UTC (History)
3 users (show)

See Also:


Attachments
patch (2.83 KB, patch)
2009-12-03 02:44 UTC, TimoB
Details | Diff
new API version (3.10 KB, application/octet-stream)
2009-12-10 06:52 UTC, Pavel Boyko
Details
average.h with unbiased variance estimate (3.13 KB, application/octet-stream)
2009-12-11 07:34 UTC, Pavel Boyko
Details

Note You need to log in before you can comment on or make changes to this bug.
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