python计算entropy - Shuang0420/Shuang0420.github.io GitHub Wiki

import scipy as sp
from scipy import stats

# calculate the entropy
pk=(0.8,0.2)
entropy=sp.stats.entropy(pk,base=2)
entropy