In [3]:
import numpy as np

def KL(a, b):
    a = np.asarray(a, dtype=np.float)
    b = np.asarray(b, dtype=np.float)

    return np.sum(np.where(a != 0, a * np.log(a / b), 0))


values1 = [1.346112,1.337432,1.246655]
values2 = [1.033836,1.082015,1.117323]

prob1 = [0.01,0.50,0.49]
prob2 = [0.25,0.25,0.5]

KL(prob1,prob2)


Out[3]:
0.30448550544570613

In [4]:
import scipy.stats as stats


stats.entropy(prob1,prob2)


Out[4]:
0.30448550544570613