Last active
April 8, 2024 20:27
-
-
Save ThomasParistech/11b7682e7ee19718b6450ea73febe4cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
def reflective_kde(x_data: np.ndarray, x_prediction: np.ndarray) -> np.ndarray: | |
h = silverman_bandwidth(x_data) # Compute before adding reflected data | |
x_data_augmented = np.stack((-x_data, x_data, 2-x_data)) | |
reflective_densities = basic_kde(x_data_augmented, x_prediction, h) | |
# Discard left and right reflected samples and normalize density by 1/3 | |
return 3 * reflective_densities | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment