Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Pengyuan Zhou pengyuan-zhou

🏠
Working from home
View GitHub Profile
View kl_similarity.py
import scipy
import numpy as np
from collections import Counter
# Kullback–Leibler divergence
# https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
# http://scipy.github.io/devdocs/generated/scipy.stats.entropy.html
def kl(p, q):
# compute common elements