Probability & Information Theory (algebrax.probability)¶
algebrax.probability provides statistical physics and information-theoretic metrics:
- Stationary Distributions (
markov_steady_state): Solves principal eigenvector equilibrium \(\pi P = \pi\). - Shannon Entropy (
entropy): Measures state information content \(H(P) = -\sum p_i \ln p_i\). - Kullback-Leibler Divergence (
kl_divergence): Relative entropy between distributions. - Jensen-Shannon Divergence (
js_divergence): Symmetric information distance. - Mutual Information (
mutual_information): Information leakage audit.
PageRank (Algebraic)¶
PageRank is the stationary distribution of a random walk on a graph. Algebraically, it is the principal eigenvector of the transition matrix.
We can compute it using Power Iteration (repeated matrix-vector multiplication).
\[v_{t+1} = \alpha M v_t + (1-\alpha) \frac{1}{N} \mathbf{1}\]
Where: * \(M\) is the column-stochastic transition matrix. * \(\alpha\) is the damping factor (usually 0.85).
Boundary Preconditions & State Safety¶
To fail fast on invalid probabilistic inputs and prevent aliased state mutation:
- Information-Theoretic Functions (
entropy,cross_entropy,kl_divergence,mutual_information): - Require a finite logarithm base
base > 0withbase != 1(booleans,NaN, and±infraiseValueError). - Reject negative, boolean,
NaN, or non-finite probability entries withValueError. - Bayesian Updates (
bayes_update): - When
evidenceis supplied explicitly, it must be finite and strictly positive (evidence <= 0,NaN, orboolraisesValueErroreven ifpriorandlikelihoodhave disjoint support). - When
evidence=Noneandpriorandlikelihoodhave disjoint support, returns{}. - Markov Transitions (
markov_step): stepsmust be a non-negative integer (negative integers and booleans raiseValueError).steps=0returns a fresh non-aliased shallow copydict(state)so mutating the result never mutates the caller's state dictionary.
Related Recipes & Applications¶
- Post-Quantum Cryptography — Zero leakage verification via
mutual_information. - Supply Chain Logistics — Demand distribution divergence via
kl_divergence. - Natural Language Parsing — Parse tree structural ambiguity via
entropy.