Skip to main content

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

# 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-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

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

minfo-0.0.5.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

minfo-0.0.5-cp37-cp37m-macosx_10_9_x86_64.whl (31.7 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

Details for the file minfo-0.0.5.tar.gz.

File metadata

  • Download URL: minfo-0.0.5.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.8

File hashes

Hashes for minfo-0.0.5.tar.gz
Algorithm Hash digest
SHA256 58b77a1412359a341811f797f7a9a216063880146125a6475bc3d97b764e6e7b
MD5 6615eb1710286b8e9096f472d7c97d78
BLAKE2b-256 509c63ba39c21bb36a983f346057d8024cd65157af7f7a00caece0e54eeb7248

See more details on using hashes here.

File details

Details for the file minfo-0.0.5-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for minfo-0.0.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c14b29dd5e23b2422fb0a751067e745cd1cd46421530b1e46bbc27bf1667e8f0
MD5 bcf771628d170a2db8c957bbd604bdd0
BLAKE2b-256 49e33cec0410d50bb907f43c5be8d1c9c608ad10573de7fd3225c66c1613e493

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page