Skip to main content

Invariant entropy estimation using nearest neighbor methods

Project description

entropy-invariant

A Python package implementing an improved nearest neighbor method for estimating differential entropy for continuous variables. This is a port of the Julia EntropyInvariant package.

Key Features

  • Invariant under change of variables: Scale and translation invariant entropy estimation
  • Always positive: Solves Edwin Thompson Jaynes' limiting density of discrete points problem
  • Multiple methods: Supports invariant (default), k-NN, and histogram methods

Installation

pip install entropy-invariant

Or install from source:

pip install -e .

Usage

import numpy as np
from entropy_invariant import entropy, mutual_information

# Generate random data
n = 1000
x = np.random.rand(n)
y = 2 * x + np.random.rand(n)

# Compute entropy (invariant method, default)
h = entropy(x)
print(f"Entropy: {h}")

# Entropy is invariant under scaling and translation
h_scaled = entropy(1e5 * x - 123.456)
print(f"Entropy (scaled): {h_scaled}")  # Same value!

# Mutual information
mi = mutual_information(x, y)
print(f"Mutual Information: {mi}")

# Different methods
h_knn = entropy(x, method="knn")
h_hist = entropy(x, method="histogram", nbins=20)

Available Functions

Core Entropy

  • entropy(X, method="inv", k=3, base=e, ...) - Unified entropy interface
  • entropy_inv(X, ...) - Invariant method (default)
  • entropy_knn(X, ...) - k-NN method
  • entropy_hist(X, ...) - Histogram method

Information Theory

  • conditional_entropy(X, Y, ...) - H(Y|X)
  • mutual_information(X, Y, ...) - I(X;Y)
  • conditional_mutual_information(X, Y, Z, ...) - I(X;Y|Z)
  • normalized_mutual_information(X, Y, ...) - NMI
  • interaction_information(X, Y, Z, ...) - Three-way interaction

Partial Information Decomposition

  • redundancy(X, Y, Z, ...) - Shared information
  • unique(X, Y, Z, ...) - Unique information
  • synergy(X, Y, Z, ...) - Synergistic information

Optimized Matrix Functions

  • MI(X, ...) - Pairwise mutual information matrix
  • CMI(X, Z, ...) - Pairwise conditional MI matrix

Authors

  • Felix Truong
  • Alexandre Giuliani

License

MIT

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

entropy_invariant-1.1.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entropy_invariant-1.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file entropy_invariant-1.1.0.tar.gz.

File metadata

  • Download URL: entropy_invariant-1.1.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for entropy_invariant-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2d2997d17d3344af5e9729ce1b675515f502bd070e4cb93176c8d5962aff27c2
MD5 d905dae550f066c52358ff6fc25057f7
BLAKE2b-256 2b82d06fb4886961abc3e18961830e2bf546a0bde8937bfb856ebf96605d867e

See more details on using hashes here.

File details

Details for the file entropy_invariant-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for entropy_invariant-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73f3347002535c12c75ab3636d1e5054a6cade807262835cae99951d5d88cf4a
MD5 92b80d934674450be30007e4f5e0e7ff
BLAKE2b-256 bccbd2a8745056a34779ad6f4b4c6e2ae0e511e91cfa4f9d266775756a931b20

See more details on using hashes here.

Supported by

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