ELIFE-ASU / PyInform

A Python Wrapper for the Inform Information Analysis Library
https://elife-asu.github.io/PyInform
MIT License
45 stars 9 forks source link

Conditional Entropy #9

Closed dglmoore closed 7 years ago

dglmoore commented 7 years ago

Inform added conditional entropy in the v0.0.5 release. The next release of PyInform should include a wrapper for conditional entropy.

Proposed API

def conditional_entropy(xs, ys, bx=0, by=0, base=2.0, local=False):

Example Usage

from pyinform.conditionalentropy import conditional_entropy

xs = [0,0,1,1,1,1,0,0,0]
ys = [1,0,0,1,0,0,1,0,0]

conditional_entropy(xs, ys) # == 0.899985
conditional_entropy(ys, xs) # == 0.972765

conditional_entropy(xs, ys, local=True)
# == [1.322, 0.737, 0.415, 2.000, 0.415, 0.415, 1.322, 0.737, 0.737]
conditional_entropy(ys, xs, local=True)
# == [0.585, 1.000, 1.000, 1.585, 1.000, 1.000, 0.585, 1.000, 1.000]