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

Bug in calculating local transfer entropy #39

Open wirkuttis opened 1 year ago

wirkuttis commented 1 year ago

Hi there,

Thanks for the great library! I discovered the following bug.

In the documentation Transfer Entropy considers X as Source input and Y as Target input. https://elife-asu.github.io/PyInform/timeseries.html#notation

In the source code, transfer entropy is calculated as transfer_entropy(source, target, k, condition=None, local=False) but in the preprocessing the source is assigned to ys = np.ascontiguousarray(source, np.int32) (which should be assigned to xs) and the target to xs = np.ascontiguousarray(target, np.int32) (which should be ys).

As a result _local_transfer_entropy(ys, xs) seems to provide the reversed result of information flow from source to target distribution rather than a target to the source distribution.