1313
2011-12-14 13:13:00 -0500
Stddev (average.h) returning NaN
2012-03-20 15:07:36 -0400
1
1
1
Unclassified
ns-3
stats
pre-release
All
All
RESOLVED
FIXED
P5
normal
---
1
tomh
watrous
ns-bugs
tjkopena
oldest_to_newest
7074
0
tomh
2011-12-14 13:13:12 -0500
It has been reported by Nicholas Loulloudes that Stddev() in src/tools/average.h can return NaN on a non-empty list. Discussion here:
http://mailman.isi.edu/pipermail/ns-developers/2011-December/009699.html
Doxygen updates and possible code updates may be needed.
Also, the return values for the empty list may not be consistent between src/tools/average.h and src/stats/model/basic-data-calculators.h. The convention seems to be to return NaN for empty list; e.g.
http://commons.apache.org/math/apidocs/org/apache/commons/math/stat/StatUtils.html
7587
1
tommaso.pecorella
2012-03-18 18:51:06 -0400
Just to summarize (and maybe close) this bug.
The analysis is wrong, as in "Count () / (double)(Count () - 1) * (m_avg2 - m_avg*m_avg)" the "(m_avg2 - m_avg*m_avg)" part is not at denominator.
The above code will return:
- 0 for Count = 0 (kinda stupid, but still)
- NaN for Count = 1 (it's expected and should be)
- a value, in all the other cases, with the special case:
-- 0 for a constant input (and this is as expected too).
Note that in the last case it is possible to have a near-zero result due to finite precision arithmetic.
Anyway, the issue remains, as we do have two different places where the calcs are done in slightly different ways. My proposal (at the time and now) is to merge them. Sadly, it's not that simple.
Checking the two implementations, one can see that:
1) the one in stats/model/basic-data-calculators.h is more complete (does more things) and it's also more precise, as it's implementing exactly the well-known Knuth's algorithm.
2) the one in tools/model/average.h is a more naive implementation (although not totally wrong) and might lead to drifts for large sequences.
So the obvious conclusion would be to use the basic-data-calculators.h one, but it's in a module and the dependencies would be not right. So the only left solution is:
a) pick the basic-data-calculators.h algorithm and improve the one in average.h
b) have basic-data-calculators.h rely on average.h functions
c) close this.
Anybody feeling like to do it ?
Cheers,
T.
7596
2
watrous
2012-03-20 12:56:45 -0400
Bug closed.
ns-3-dev changeset: f794f31dc0be
7598
3
tommaso.pecorella
2012-03-20 14:27:19 -0400
Considering that in tools module there is:
module = bld.create_ns3_module('tools', ['network'])
and in stats module there is:
obj = bld.create_ns3_module('stats', ['network'])
there is no apparent dependency. However there is.
Shouldn't the tools one be:
module = bld.create_ns3_module('tools', ['network', 'stats']) ?
Cheers,
T.
7599
4
watrous
2012-03-20 14:46:28 -0400
(In reply to comment #3)
> Considering that in tools module there is:
> module = bld.create_ns3_module('tools', ['network'])
>
> and in stats module there is:
> obj = bld.create_ns3_module('stats', ['network'])
>
> there is no apparent dependency. However there is.
>
> Shouldn't the tools one be:
> module = bld.create_ns3_module('tools', ['network', 'stats']) ?
>
> Cheers,
>
> T.
I did just what you suggested. Here is the relevant line from
src/tools/wscript
that specifies the tools module's dependencies:
module = bld.create_ns3_module('tools', ['network', 'stats'])
7600
5
tommaso.pecorella
2012-03-20 15:07:36 -0400
Sry, didn't see that line. Nvm :)
Ty,