|
Bugzilla – Full Text Bug Listing |
| Summary: | EmpiricalRandomVariable::Validate () fails if the value provided in the CDF member function is negative. | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Rubén Martínez <rmartinez> |
| Component: | core | Assignee: | Mathieu Lacage <mathieu.lacage> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | ns-bugs, tomh |
| Priority: | P5 | ||
| Version: | ns-3-dev | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | EmpiricalVariable patch | ||
I confirmed this and agree with (and tested) the patch (although the example provided should use Ptr<EmpiricalRandomVariable> uv = CreateObject<EmpiricalRandomVariable> (); ) I will apply tomorrow if no other comments. pushed in changeset 11278:4213cff834ff |
Created attachment 1997 [details] EmpiricalVariable patch If the provided empirical CDF contains negative values in the X axis this function will always report an error (and it should not). This issue can be reproduced like this: EmpiricalRandomVariable uv; uv.CDF(-0.1,0.1); uv.CDF(0, 0.2); uv.CDF(0.1, 0.3); uv.GetValue(); The problem is: Line 1601: if (current.value < prior.value || current.cdf < prior.cdf) Which is true in the first iteration because the "prior" variable is initialized by its default constructor: Line 1597: ValueCDF prior; Which sets prior.value = 0 and prior.cdf = 0. A possible fix would be to assign the first element of the empirical distribution: Line 1597: ValueCDF prior = emp[0];