def entropies(pdf, variable, conditional_variable, logbase="log2"): """ Input: pdf joint pdf class variable the variable to calculate the entropy. Could fit multiple labels (e.g. "var" fits "var_1", "var_2", "var_3",...) conditional_variable conditional variable logbase Base for the logarithm ("log2", "log", "log10") returns mutual information based on conditional entropy """ return shannon.calculate(pdf, variable, logbase) - shannon.conditional(pdf, variable, conditional_variable, logbase)
def entropies(pdf, cond_pdf, logbase="log2"): ''' Mutual information metric based on entropies. Input: pdf_a probability A variable NxB N = elements B = bins cond_pdf conditional probability NxBAxBB N = elements BA = bins A BB = bins B logbase Base for the logarithm ("log2", "log", "log10") Returns: mutual information N N = elements ''' return shannon.calculate(pdf, logbase) - shannon.conditional(pdf, cond_pdf, logbase)