Skip to content

Instantly share code, notes, and snippets.

View koshian2's full-sized avatar

こしあん koshian2

View GitHub Profile
@atabakd
atabakd / kl.py
Last active July 5, 2024 19:47
KL divergence for multivariate samples
# https://mail.python.org/pipermail/scipy-user/2011-May/029521.html
import numpy as np
def KLdivergence(x, y):
"""Compute the Kullback-Leibler divergence between two multivariate samples.
Parameters
----------
x : 2D array (n,d)