kde_val = np.asarray([kde.integrate_box_1d(-np.inf, xx) for xx in x])
kdev = np.minimum(kde_val, 1 - kde_val)
Calculate how a value differs from the average of values using the Gaussian Kernel Density (Python)