Belle II Software development
CDF Class Reference
Inheritance diagram for CDF:
Transform ProTool

Public Member Functions

def __init__ (self, *args)
 

Public Attributes

 spline
 Spline, fitting the CDF.
 

Protected Member Functions

def _fit (self, x, y=None)
 
def _transform (self, x)
 

Detailed Description

Calculates the cumulative distribution (CDF)
Can be used for the flat transformation.

Attributes
----------
spline : InterpolatedUnivariateSpline
    Spline, fitting the CDF

Definition at line 176 of file transform.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
args 
)
 Init function

:param args: None

Reimplemented from Transform.

Definition at line 189 of file transform.py.

189 def __init__(self, *args):
190 """ Init function
191
192 :param args: None
193 """
194 Transform.__init__(self, "CDF", *args)
195
196
197 self.spline = None
198

Member Function Documentation

◆ _fit()

def _fit (   self,
  x,
  y = None 
)
protected
Fit function calculates the cumulative distribution with numpy percentile.

:param x:   Input distribution
:param y:   Will not be used in this transformation

Reimplemented from Transform.

Definition at line 199 of file transform.py.

199 def _fit(self, x, y=None):
200 """
201 Fit function calculates the cumulative distribution with numpy percentile.
202
203 :param x: Input distribution
204 :param y: Will not be used in this transformation
205 """
206 self.io.debug("Fitting CDF")
207 y_ = np.linspace(0, 100, 2 * self.n_bins)
208 x_ = pd.Series(np.percentile(x, list(y_)))
209
210 # Count same values
211 vc = x_.value_counts()
212 vc = vc.sort_index()
213
214 # replace same values
215 for i, xi in enumerate(vc):
216 if xi > 1:
217 try:
218 nex_val = vc.index[i + 1]
219 except IndexError:
220 nex_val = vc.index[i] + 0.01
221 fill = np.linspace(vc.index[i], nex_val, xi)
222 x_[x_ == vc.index[i]] = fill
223 self.spline = InterpolatedUnivariateSpline(x_, y_)
224

◆ _transform()

def _transform (   self,
  x 
)
protected
Transforms the input data according to the cdf.
:param x:   Input data
:return:    Transformed data

Reimplemented from Transform.

Definition at line 225 of file transform.py.

225 def _transform(self, x):
226 """
227 Transforms the input data according to the cdf.
228 :param x: Input data
229 :return: Transformed data
230 """
231 x = self.set_limits(x)
232 return self.spline(x)
233
234

Member Data Documentation

◆ spline

spline

Spline, fitting the CDF.

Definition at line 197 of file transform.py.


The documentation for this class was generated from the following file: