|
Bugzilla – Full Text Bug Listing |
| Summary: | NormalVariable RNG's first returned value is not expected | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Antti Mäkelä <antti.makela> |
| Component: | core | Assignee: | ns-bugs <ns-bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | dnlove, mathieu.lacage, tomh |
| Priority: | P5 | ||
| Version: | pre-release | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Program that shows oddities in NormalVariable.
fixed the first erroneous value of GetValue from NormalVariable fixed the first erroneous value of GetValue from NormalVariable fixed the first erroneous value of GetValue from NormalVariable and removed unused variable |
||
In "src/core/random-variable.cc", the variable m_nextValid behaves a bit strange, I have no idea where it gets initialized to 248 after already being initialized to 0. Output of the order of event in my log printout from random-variable.cc: In constructor NormalVariableImpl m_nextValid 0 In NormalVariableImpl::GetValue() m_nextValid is 248 gdb debuging still shows the mysterious number 248 after it already gets assigned 0. There isn't many places where m_nextValid gets assigned, and it's a mystery why it gets that value. (In reply to comment #0) > Created an attachment (id=552) [details] > Program that shows oddities in NormalVariable. > > When using NormalVariable, the first GetValue() call after initialization > returns a rather odd value. > > Test program attached. Anyway, asking for 10 random values returns > > 1.06956e-311 > 13.8052 > 11.2844 > 9.71656 > 2.41641 > 8.41882 > 13.7028 > 7.21069 > 10.5926 > 11.8275 > Created attachment 563 [details]
fixed the first erroneous value of GetValue from NormalVariable
Apparently, we also must initialize variable m_nextValid in NormalVariableImpl::NormalVariableImpl(const NormalVariableImpl& c) as well.
Please see the patch. I reran your example script it outputs fine now.
13.8052
11.2844
9.71656
2.41641
8.41882
13.7028
7.21069
10.5926
11.8275
10.5249
14.0481
Created attachment 564 [details]
fixed the first erroneous value of GetValue from NormalVariable
same patch, just rearrange it a bit to look nice.
Seems to work now. if --regression still passes, please commit I see that m_static_nextValid and m_static_next are unused: can you kill them in a separate patch if I am right and --regression still passes ? Created attachment 565 [details]
fixed the first erroneous value of GetValue from NormalVariable and removed unused variable
fixed the erroneous first return of NormalVariable and removed unused variable "static bool m_static_nextValid;"
"static double m_static_next;"
it passes regression tests, but I don't know how to commit, do you mean change the resolution to "fixed" and click "commit" and it will be applied in ns-3-dev? (In reply to comment #5) > if --regression still passes, please commit > > I see that m_static_nextValid and m_static_next are unused: can you kill them > in a separate patch if I am right and --regression still passes ? > (In reply to comment #7) > it passes regression tests, but I don't know how to commit, do you mean change > the resolution to "fixed" and click "commit" and it will be applied in > ns-3-dev? No, bugzilla is not linked to the repository in that way. I'll contact you about this. pushed in changeset 4736 fef6ccee5897 |
Created attachment 552 [details] Program that shows oddities in NormalVariable. When using NormalVariable, the first GetValue() call after initialization returns a rather odd value. Test program attached. Anyway, asking for 10 random values returns 1.06956e-311 13.8052 11.2844 9.71656 2.41641 8.41882 13.7028 7.21069 10.5926 11.8275