Mutual Information Estimator
Python-based mutual information estimator, designed for multiple data types.
Prerequisite
# Make sure install numpy using conda.
# Installation with pip may lead to unexpected errors.
conda install numpy cython numba
Install OpenMP Library
Install OpenMP Library to enable CPU parallel acceleration for Time-delayed Mutual Information calculation.Linux:
sudo apt-get install libomp-devMacOS:
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
Metadata
Release files for minfo 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| minfo-0.0.7.tar.gz | 37.4 kB | Without provenance | Details for minfo-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| minfo-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl | CPython 3.10 | CPython 3.10 | macOS 10.9+ x86-64 | Details for minfo-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl |
Total release size: 67.1 kB
Release files / minfo-0.0.7.tar.gz
| Download URL | minfo-0.0.7.tar.gz |
|---|---|
| Size | 37.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f172859a379e65b3c375cc8333fc38b64bd37e0ee09091ff63c146127275f1f
|
|
BLAKE2b-256 checksum How to use checksums |
8debf6a65ab92f967a91aa4eccb3d527f3bf5f2a3ad3346db01032b7ad04b2c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / minfo-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | minfo-0.0.7-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 29.7 kB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
e1a27db8be19354241a0664bd62a46f597099ae5956805d94f6612846f1d63b6
|
|
BLAKE2b-256 checksum How to use checksums |
3c228a1aef3617ab36e9f6d4e59e4e0c981ea02baaa925618fe07e298539fb84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Security for minfo 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.