From 09287b3f9e6bfbb9408471cc0ed10c0006c7fcbb Mon Sep 17 00:00:00 2001 From: "Michele.Maris" <michele.maris@inaf.it> Date: Wed, 12 Jun 2024 11:18:22 +0200 Subject: [PATCH] u --- src/yapsut/stats.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yapsut/stats.py b/src/yapsut/stats.py index ff58bfb..5102438 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 -- GitLab