def shannoninfo(px, logbase=2):
 px = np.asarray(px)
 if ((not np.all((px <= 1))) or (not np.all((px >= 0)))):
  raise ValueError('px does not define proper distribution')
 if (logbase != 2):
  return ((- logbasechange(2, logbase)) * np.log2(px))
 else:
  return (- np.log2(px))

def shannoninfo ( px , logbase = 2 ) : px = np . asarray ( px ) if ( ( not np . all ( ( px <= 1 ) ) ) or ( not np . all ( ( px >= 0 ) ) ) ) : raise ValueError ( 'px does not define proper distribution' ) if ( logbase != 2 ) : return ( ( - logbasechange ( 2 , logbase ) ) * np . log2 ( px ) ) else : return ( - np . log2 ( px ) )
shannons information parameters px : float or array-like px is a discrete probability distribution returns for logbase = 2 np .