High-performance Rust library for information-theoretic measures with multiple estimation approaches.
infomeasure-rs computes entropy, mutual information, and transfer entropy from data using four different estimation strategies:
- Discrete: For categorical data with 11+ bias-corrected estimators
- Kernel: For continuous data with optional GPU acceleration
- Ordinal: For time series using permutation patterns
- Exponential Family: For high-dimensional data using k-NN
[dependencies]
infomeasure = "0.1.0"Enable GPU acceleration for large datasets:
infomeasure = { version = "0.1.0", features = ["gpu"] }Enable fast exponential approximations:
infomeasure = { version = "0.1.0", features = ["fast_exp"] }use infomeasure::estimators::entropy::Entropy;
use ndarray::array;
// Discrete entropy
let data = array!(1, 2, 1, 3, 2, 1);
let entropy = Entropy::new_discrete(data).global_value();
println!("Entropy: {}", entropy);
// Continuous data with kernel estimation
let continuous = array![[1.0, 1.5], [2.0, 3.0], [4.0, 5.0]];
let kernel_entropy = Entropy::nd_kernel::<2>(continuous, 1.0).global_value();
println!("Kernel entropy: {}", kernel_entropy);| Feature | Discrete | Kernel | Ordinal | k-NN |
|---|---|---|---|---|
| Entropy | ✅ | ✅ | ✅ | ✅ |
| Mutual Information | ✅ | ✅ | ✅ | ✅ |
| Transfer Entropy | ✅ | ✅ | ✅ | ✅ |
✅ = Available | 🔄 = In Development | ❌ = Planned
- API Reference - Complete documentation
- Examples - Usage examples
Enable GPU computation for large datasets:
infomeasure = { version = "0.1.0", features = ["gpu"] }Fast exponential approximations:
infomeasure = { version = "0.1.0", features = ["fast_exp"] }This crate maintains API compatibility with the infomeasure Python package while providing 10-100x performance improvements.
src/- Main source codeestimators/- Estimation techniques implementationsapproaches/- Specific implementations (discrete, kernel, ...)traits/- Shared interfaces for estimators
benches/- Performance benchmarks using Criteriontests/- Unit and integration testsexamples/- Example usage and demonstrations
- Rust 1.70+ (for building)
- uv Python package manager (for validation tests)
The validation tests require a Python environment with infomeasure package.
Set it up once before running tests:
# Create virtual environment in validation crate directory
cd tests/validation_crate
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
uv pip install -r requirements.txt# Run all tests (includes Python validation)
cargo test
# Run only Rust unit tests (skip Python validation)
cargo test --libThe project includes a validation crate that compares results with Python implementation to ensure compatibility and correctness.
Performance benchmarks are available for different estimation methods:
cargo benchContributions welcome! Please feel free to submit a Pull Request.
MIT OR Apache-2.0