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 Transfer Entropy #31

Closed kjaquier closed 4 years ago

kjaquier commented 4 years ago

In Inform, inform_transfer_entropy supports conditional TE through its third argument (int const *back), which is simply set to None in PyInform. It should be rather straightforward to implement.

Proposed API

transfer_entropy(source, target, k, background=None, b=0, local=False)

Example Usage

From https://elife-asu.github.io/Inform/#transfer-entropy

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

transfer_entropy(xs, ys, background=ws, b=2, k=2)
# 0.285714

ws = [[1,0,1,0,1,1,1,1,1],
      [1,1,0,1,0,1,1,1,1]]

transfer_entropy(xs, ys, background=ws, b=2, k=2)
# 0.0
dglmoore commented 4 years ago

@kjaquier Done (#32). I'll try to get a new release version out in the next 24 hours.

kjaquier commented 4 years ago

Great work! Thanks

dglmoore commented 4 years ago

Actually, I just release v0.2.0. You should be able to pip install --upgrade pyinform. One thing to note is this will take you directly from v0.0.5, skipping some API changes in v0.1.0 (released earlier this week). The only one that is likely to affect you is there is no longer a b= argument for most of the functions. Also, all functions now compute the various information measures using base-2 logarithms.