Skip to content

Commit

Permalink
Merge branch 'sparse-kde' of https://github.com/GardevoirX/scikit-matter
Browse files Browse the repository at this point in the history
 into sparse-kde
  • Loading branch information
GardevoirX committed Aug 7, 2024
2 parents 34e6312 + e965f99 commit 7d1abad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/neighbors/sparse-kde.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,12 @@ def rij(period: np.ndarray, xi: np.ndarray, xj: np.ndarray) -> np.ndarray:
# several minutes to run)

# %%
data = np.vstack([x.ravel(), y.ravel()])
start = time.time()
kde = gaussian_kde(samples.T)
sklearn_probs = kde(np.vstack([x.ravel(), y.ravel()])).T
sklearn_probs = kde(data).T
end = time.time()
print(f"Time sklearn: {end-start}s")
RMSE_kde = np.sum(
(probs - sklearn_probs) ** 2 * (x[0][1] - x[0][0]) * (y[1][0] - y[0][0])
)
Expand Down

0 comments on commit 7d1abad

Please sign in to comment.