Skip to content
Snippets Groups Projects
Commit 09287b3f authored by Michele Maris's avatar Michele Maris
Browse files

u

parent 1a60c8b5
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ class CumulativeOfData : ...@@ -39,7 +39,7 @@ class CumulativeOfData :
""" """
return np.interp(x,self._x,self._eff,left=0.,right=1.) return np.interp(x,self._x,self._eff,left=0.,right=1.)
# #
def sampled_pdf(self,x,method='hist') : def sampled_pdf(self,x,method='hist',density=False) :
"""returns the sample pdf for a list of x """returns the sample pdf for a list of x
output: hh, xx output: hh, xx
...@@ -47,6 +47,8 @@ class CumulativeOfData : ...@@ -47,6 +47,8 @@ class CumulativeOfData :
if method = 'hist' the pdf is calculated using an histogram like function (default) if method = 'hist' the pdf is calculated using an histogram like function (default)
if method = 'tan' the pdf is calculated using the local tangent to the cdf if method = 'tan' the pdf is calculated using the local tangent to the cdf
if method = 'hist' and density = True, hh is normalized to the step size and represents an approximation of the local derivative
""" """
if not method in ['hist','tan'] : if not method in ['hist','tan'] :
raise Exception("Error: method must be either 'hist' or 'tan'") raise Exception("Error: method must be either 'hist' or 'tan'")
...@@ -59,7 +61,7 @@ class CumulativeOfData : ...@@ -59,7 +61,7 @@ class CumulativeOfData :
_x=np.sort(x) _x=np.sort(x)
# #
yy=self.cdf(_x) yy=self.cdf(_x)
hh=(yy[:-1]-yy[1:])/(_x[:-1]-_x[1:]) hh=(yy[1:]-yy[:-1])/(_x[1:]-_x[:-1]) if density else yy[1:]-yy[:-1]
return hh, _x return hh, _x
elif method == 'tan' : elif method == 'tan' :
h=(self._x[-1]-self._x[0])*eps h=(self._x[-1]-self._x[0])*eps
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment