[closes #187] pdf methods for some values like expectation and plotting ready

This commit is contained in:
Sebastian Wehling-Benatelli 2016-03-04 14:13:44 +01:00
parent e6b5848f36
commit 9f7f00314a

View File

@ -157,7 +157,7 @@ class ProbabilityDensityFunction(object):
return ProbabilityDensityFunction(x0, incr, npts, pdf)
def __nonzero__(self):
return True
return bool(np.round(self.prob_gt_val(self.axis[0]), 4) == 1.)
@property
def data(self):
@ -259,6 +259,18 @@ class ProbabilityDensityFunction(object):
return None
return self.data[find_nearest(self.axis, value)] * self.incr
def plot(self):
import matplotlib.pyplot as plt
plt.plot(self.axis, self.data)
plt.xlabel('x')
plt.ylabel('f(x)')
if self:
plt.title('Probability density function')
else:
plt.title('Function not suitable as probability density function')
plt.show()
def commonlimits(self, incr, other, max_npts=1e5):
'''
Takes an increment incr and two left and two right limits and returns