def cumulative_smooth(self, x_min, x_max, npoints=200):
"""
This function ...
:param x_min:
:param x_max:
:param npoints:
:return:
"""
if self._cum_smooth is None:
x_smooth, y_smooth = self.smooth_values(x_min, x_max, npoints)
# Set negative values to zero
y_smooth[y_smooth < 0.0] = 0.0
# Normalize y by calculating the integral
#total = simps(y_smooth, x_smooth)
# NO, by calculating the sum (why?)
total = np.sum(y_smooth)
# Now, y should be normalized within x_min:x_max
y_smooth /= total
# Return the cumulative distribution
#return x_smooth, np.cumsum(y_smooth)
self._cum_smooth = (x_smooth, np.cumsum(y_smooth))
return self._cum_smooth
# -----------------------------------------------------------------
评论列表
文章目录