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 April 11, 2024 11:31
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)