Created
February 26, 2024 16:20
-
-
Save ThomasParistech/51aca92d7039a278c1389f340248ff57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.stats import norm | |
def weighted_kde(x_data: np.ndarray, x_prediction: np.ndarray) -> np.ndarray: | |
h = silverman_bandwidth(x_data) # Required to evaluate CDF | |
area_values = norm.cdf(1.0, x_prediction, h) - norm.cdf(0.0, x_prediction, h) | |
basic_densities = basic_kde(x_data, x_prediction, h) | |
return basic_densities / area_values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment