[fix] fixed the nonzero test for pdf definition that all values have to be greater than zero and the integration over the whole interval has to evaluate to 1 with given precision
This commit is contained in:
parent
a5fe838514
commit
15080f1699
@ -151,11 +151,18 @@ class ProbabilityDensityFunction(object):
|
|||||||
return ProbabilityDensityFunction(x0, incr, npts, pdf)
|
return ProbabilityDensityFunction(x0, incr, npts, pdf)
|
||||||
|
|
||||||
def __nonzero__(self):
|
def __nonzero__(self):
|
||||||
return bool(np.round(self.prob_gt_val(self.axis[0]), 4) == 1.)
|
prec = self.precision(self.incr)
|
||||||
|
gtzero = np.any(self.data >= 0)
|
||||||
|
probone = bool(np.round(self.prob_gt_val(self.axis[0]), prec) == 1.)
|
||||||
|
return (gtzero and probone)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.data)
|
return str(self.data)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def precision(incr):
|
||||||
|
return int(np.ceil(np.abs(np.log10(incr))))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
return self._pdf
|
return self._pdf
|
||||||
@ -307,7 +314,7 @@ class ProbabilityDensityFunction(object):
|
|||||||
x0 = l2
|
x0 = l2
|
||||||
|
|
||||||
# calculate index for rounding
|
# calculate index for rounding
|
||||||
ri = int(np.ceil(np.abs(np.log10(incr))))
|
ri = self.precision(incr)
|
||||||
|
|
||||||
if r1 < r2:
|
if r1 < r2:
|
||||||
npts = int(round(r2 - x0, ri) // incr)
|
npts = int(round(r2 - x0, ri) // incr)
|
||||||
|
Loading…
Reference in New Issue
Block a user