def condentropy(px, py, pxpy=None, logbase=2):
 if ((not _isproperdist(px)) or (not _isproperdist(py))):
  raise ValueError('px or py is not a proper probability distribution')
 if ((pxpy != None) and (not _isproperdist(pxpy))):
  raise ValueError('pxpy is not a proper joint distribtion')
 if (pxpy == None):
  pxpy = np.outer(py, px)
 condent = np.sum((pxpy * np.nan_to_num(np.log2((py / pxpy)))))
 if (logbase == 2):
  return condent
 else:
  return (logbasechange(2, logbase) * condent)

def condentropy ( px , py , pxpy = None , logbase = 2 ) : if ( ( not _isproperdist ( px ) ) or ( not _isproperdist ( py ) ) ) : raise ValueError ( 'px or py is not a proper probability distribution' ) if ( ( pxpy != None ) and ( not _isproperdist ( pxpy ) ) ) : raise ValueError ( 'pxpy is not a proper joint distribtion' ) if ( pxpy == None ) : pxpy = np . outer ( py , px ) condent = np . sum ( ( pxpy * np . nan_to_num ( np . log2 ( ( py / pxpy ) ) ) ) ) if ( logbase == 2 ) : return condent else : return ( logbasechange ( 2 , logbase ) * condent )
return the conditional entropy of x given y .