Python-based mutual information estimator, designed for multiple data types.
Project description
Mutual Information Estimator
Python-based mutual information estimator, designed for multiple data types.
Prerequisite
Install OpenMP Library
Install OpenMP Library to enable CPU parallel acceleration for Time-delayed Mutual Information calculation.Linux:
sudo apt-get install libomp-dev
MacOS:
brew install libomp
Installation
To install via pip:
pip install minfo
To install via repository:
git clone https://github.com/NeoNeuron/minfo
cd minfo
pip install -e .
Get Started
MI with uniform bins
from minfo.mi_float import mutual_info, TDMI
# mutual_info : mutual information estimator
# tdmi : time-delayed mutual information estimator
n = 100
x = np.random.rand(n)
y = np.random.rand(n)
# compute mutual information
mutual_info(x,y, bins=50) # default algorithm: 'uniform'
# compute time-delayed mutual information (Parallel accelerated)
n_delay = 10
TDMI(x, y, n_delay, bins=50) # default algorithm: 'uniform'
MI with adaptive bins
ATTENTION: This algorithm is designed for mutual information estimation between continuous variables. Applying it to discrete variables with few number of values might lead to large deviations. Modules for finite discrete cases are to be developed.
Reference
- Darbellay, G. A., & Vajda, I. (1999). Estimation of the information by an adaptive partitioning of the observation space. IEEE Transactions on Information Theory, 45(4), 1315-1321.
from minfo.mi_float import mutual_info, TDMI
# mutual_info : mutual information estimator
# tdmi : time-delayed mutual information estimator
n = 100
x = np.random.rand(n)
y = np.random.rand(n)
# compute mutual information
mutual_info(x,y, algorithm='adaptive')
# compute time-delayed mutual information (Parallel accelerated)
n_delay = 10
TDMI(x, y, n_delay, algorithm='adaptive')
Compare performance with pure Python version
Test OS info:
- Laptop: MacBook Pro (15-inch, 2018)
- System version: macOS Big Sur 12.4 (21F79)
- CPU: 2.6 GHz 6-Core Intel Core i7
- RAM: 32 GB 2400 MHz DDR4
$ cd example
$ python example.py
[INFO]: mi_adaptive (python) takes 0.025 s
[INFO]: mi_uniform (numba) takes 0.000 s
[INFO]: mi_adaptive (cython) takes 0.009 s
[INFO]: tdmi_adaptive (python) takes 0.560 s
[INFO]: tdmi_uniform (numba) takes 0.005 s
[INFO]: tdmi_adaptive (cython) takes 0.076 s
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file minfo-0.0.6.tar.gz
.
File metadata
- Download URL: minfo-0.0.6.tar.gz
- Upload date:
- Size: 37.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13c850d75dfa7560649236063311878396fffa1a67d94cbfe5bbece3142bb654 |
|
MD5 | cb5c55a82f18ce329782e7420be48ca2 |
|
BLAKE2b-256 | f9fc62dbafa9926d46a48ddfc83dcb2c6f63656512dfeaf1d2e06c7e58647cf7 |
File details
Details for the file minfo-0.0.6-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: minfo-0.0.6-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 29.6 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68ccba05c49c86552a11fd2718760feb636e6d07e2fa3d5adb62dad36600015b |
|
MD5 | 0683b0da0fa297c7404bef22a611c6b2 |
|
BLAKE2b-256 | c0cc991340234adfb03882ee6f5180aa67c3c9e962463e93f3d4b305fb95dece |