def entropy(pk, qk=None, base=None):
 pk = asarray(pk)
 pk = ((1.0 * pk) / np.sum(pk, axis=0))
 if (qk is None):
  vec = entr(pk)
 else:
  qk = asarray(qk)
  if (len(qk) != len(pk)):
   raise ValueError('qk and pk must have same length.')
  qk = ((1.0 * qk) / np.sum(qk, axis=0))
  vec = rel_entr(pk, qk)
 S = np.sum(vec, axis=0)
 if (base is not None):
  S /= log(base)
 return S

def entropy ( pk , qk = None , base = None ) : pk = asarray ( pk ) pk = ( ( 1.0 * pk ) / np . sum ( pk , axis = 0 ) ) if ( qk is None ) : vec = entr ( pk ) else : qk = asarray ( qk ) if ( len ( qk ) != len ( pk ) ) : raise ValueError ( 'qk and pk must have same length.' ) qk = ( ( 1.0 * qk ) / np . sum ( qk , axis = 0 ) ) vec = rel_entr ( pk , qk ) S = np . sum ( vec , axis = 0 ) if ( base is not None ) : S /= log ( base ) return S
given a list of class probabilities .