code: def kde(data, npoints=_npoints):
      
      # Clipping of severe outliers to concentrate more KDE samples in the parameter range of interest
      mad = np.median(np.fabs(np.median(data) - data))
      cut = (data > np.median(data) - 5. * mad) & (data < np.median(data) + 5. * mad)
      x = data[cut]
      kde = scipy.stats.gaussian_kde(x)
      # No penalty for using a finer sampling for KDE evaluation except computation time
      values = np.linspace(np.min(x), np.max(x), npoints)
      kde_values = kde.evaluate(values)
      peak = values[np.argmax(kde_values)]
      return values[np.argmax(kde_values)], kde.evaluate(peak)
docs: Identify peak using Gaussian kernel density estimator.
      
      Parameters:
      -----------
      data   : The 1d data sample
      npoints : The number of kde points to evaluate