Expand description
Information theory — Shannon entropy, KL divergence, cross-entropy and mutual
information over discrete distributions / samples (all in bits, log₂).
Mission note: mutual information is a principled, assumption-free relevance
signal — I(X;Y) measures how much knowing X reduces uncertainty about Y
with no linearity assumption — which is exactly what the 10D→5D NQuin relevance
router needs to choose its projection.
Functions§
- cross_
entropy - Cross-entropy
H(p, q) = −Σ pᵢ·log₂ qᵢ(bits).Nonelikekl_divergence. - entropy
- Shannon entropy
H(p) = −Σ pᵢ·log₂ pᵢ(bits) of a probability vector. Zero probabilities contribute 0.Noneif empty or the masses don’t form a positive distribution. - entropy_
from_ counts - Entropy from integer counts (normalized internally).
- kl_
divergence - Kullback–Leibler divergence
D(p‖q) = Σ pᵢ·log₂(pᵢ/qᵢ)(bits). Both inputs are normalized internally.Noneon a length mismatch, empty input, or ifqᵢ = 0wherepᵢ > 0(the divergence is then infinite — refuse rather than fabricate). - mutual_
information_ discrete - Mutual information
I(X;Y) = H(X) + H(Y) − H(X,Y)(bits), estimated from paired discrete samples (small non-negative integer labels).Noneon length mismatch or empty input.I ≥ 0, andI = 0iffX ⟂ Yin the sample.