diff --git a/src/yapsut/stats.py b/src/yapsut/stats.py index ff58bfba4929081e126545a7c5f7601b10db3939..5102438115b50a4ce581c143a98b89cc616c2bba 100644 --- a/src/yapsut/stats.py +++ b/src/yapsut/stats.py @@ -39,7 +39,7 @@ class CumulativeOfData : """ 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 output: hh, xx @@ -47,6 +47,8 @@ class CumulativeOfData : 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 = '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'] : raise Exception("Error: method must be either 'hist' or 'tan'") @@ -59,7 +61,7 @@ class CumulativeOfData : _x=np.sort(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 elif method == 'tan' : h=(self._x[-1]-self._x[0])*eps