code: def kullback_leibler(p, q) :
  	
  	p = np.asarray(p, dtype=np.float)
  	q = np.asarray(q, dtype=np.float)
  
  	if p.shape != q.shape :
  		raise ValueError("p and q must be of the same dimensions")
  	
  	return np.sum(np.where(p > 0, np.log(p / q) * p, 0))
docs: Discrete Kullback-Leibler divergence D(P||Q)