[change] implementation of quantile calculation corrected
This commit is contained in:
parent
4f47f9f343
commit
e8cbc2f377
@ -297,20 +297,18 @@ class ProbabilityDensityFunction(object):
|
|||||||
def quantile(self, prob_value, eps=0.01):
|
def quantile(self, prob_value, eps=0.01):
|
||||||
l = self.axis[0]
|
l = self.axis[0]
|
||||||
r = self.axis[-1]
|
r = self.axis[-1]
|
||||||
m = (r - l) / 2
|
m = (r + l) / 2
|
||||||
diff = prob_value - self.prob_lt_val(m)
|
diff = prob_value - self.prob_lt_val(m)
|
||||||
while abs(diff) > eps:
|
while abs(diff) > eps:
|
||||||
if diff > 0:
|
if diff > 0:
|
||||||
l = m
|
l = m
|
||||||
else:
|
else:
|
||||||
r = m
|
r = m
|
||||||
m = (r - l) / 2
|
m = (r + l) / 2
|
||||||
diff = prob_value - self.prob_lt_val(m)
|
diff = prob_value - self.prob_lt_val(m)
|
||||||
|
print(m, prob_value, self.prob_lt_val(m))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
def quantile_distance(self, prob_value):
|
def quantile_distance(self, prob_value):
|
||||||
ql = self.quantile(prob_value)
|
ql = self.quantile(prob_value)
|
||||||
qu = self.quantile(1 - prob_value)
|
qu = self.quantile(1 - prob_value)
|
||||||
|
Loading…
Reference in New Issue
Block a user