Skip to content

Code to use Mutual Information as a correlation measure; using this concept, perform temporal lagging on data and hence find a lag at which peak correlation occurs.

License

Notifications You must be signed in to change notification settings

arfogg/generic_MI_lag_finder

Repository files navigation

generic_MI_lag_finder v1.0.0

DOI

This package is intended to determine coupling timescales between two sets of data or 'timeseries'. The Mutual Information (MI) content between the two timeseries is calculated at a range of different temporal lags. MI is a measure of the shared information content between two variables, independent of the order or direction of their relationship. A piecewise linear and quadratic curve are fit to the MI data as a function of temporal lag; the peak of these curves can be interpreted as the coupling timescale between the two measured phenomena.

License: CC0-1.0

Support: please create an issue or contact arfogg directly. Any input on the code / issues found are greatly appreciated and will help to improve the software.

Required Packages

scipy, matplotlib, numpy, pandas, datetime, sklearn, aaft

Install aaft from its github here

Developed using Python 3.8.8. See requirements.txt for version of packages.

Running the code

First, the code must be downloaded using git clone https://github.com/arfogg/generic_MI_lag_finder

Then, from a python terminal: import generic_mutual_information_routines

To ensure all packages are installed, and the code is working correctly run: generic_mutual_information_routines.test_mi_lag_finder()

This testing function test_mi_lag_finder will generate and plot two example signals, timeseries A and B: alt text

It will then run mi_lag_finder, and plot out the MI content as a function of applied lag: alt text

Acknowledgements

ARF gratefully acknowledges the support of Science Foundation Ireland Grant 18/FRL/6199 and Irish Research Council Government of Ireland Postdoctoral Fellowship GOIPD/2022/782.

About

Code to use Mutual Information as a correlation measure; using this concept, perform temporal lagging on data and hence find a lag at which peak correlation occurs.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages