Bugzilla – Bug 2082
EmpiricalRandomVariable::Validate () fails if the value provided in the CDF member function is negative.
Last modified: 2015-04-03 19:39:26 UTC
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];
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