lzcomplexity-core
The algorithmic core of lzcomplexity —
information-theoretic complexity measures for symbolic sequences, based on
Lempel–Ziv 76 (LZ76) factorization.
This is pure Rust with no Python or CLI dependencies. It powers the
lzcomplexity Python package (via PyO3) and the lzcomplexity / lzdistance
standalone binaries, and can be used directly as a Rust library.
What it computes
- LZ76 factorization — the complexity
c(S)(factor count) and the factor boundaries, via a linear-time suffix array + longest-previous-factor. - Entropy density — the normalized entropy-rate estimator
h ≈ c(S)·log_k(n)/n, which converges to the true entropy rate of ergodic sources. - Effective measure complexity (EMC) — a block-entropy (excess-entropy) estimator via random block shuffling.
- Normalized information distance (NID) — an LZ76-based distance between two sequences.
Usage
[]
= "1.0"
use ;
let args = new; // auto-detect alphabet / log base
// Complexity + factor boundaries: the i-th factor spans [lzf[i], lzf[i+1]).
let r = lz76_factors;
assert_eq!;
assert_eq!;
// Normalized entropy density.
let h = lz76_entropy_density;
assert!;
// Normalized information distance between two sequences.
let d = lz76_information_distance;
assert!;
See the API documentation for the full surface.
Notes
- Inputs are raw byte sequences (
Sequence::from_str/Sequence::from_bytes), so any alphabet works, including non-UTF-8 bytes. - The shuffle-based EMC is seeded deterministically from the input, so results are reproducible run-to-run.
References
- Lempel, A., & Ziv, J. (1976). On the complexity of finite sequences. IEEE Transactions on Information Theory, 22(1), 75–81.
- Kontoyiannis, I., et al. (1998). Nonparametric entropy estimation for stationary processes and random fields. IEEE TIT, 44(3), 1319–1327.
License
MIT — see LICENSE.