mixle.experimental.tensor_network module¶
P4 (experimental) – tensor-network (matrix-product-state) leaves with exact conditioning.
A matrix-product state (MPS / tensor-train) is a density model over discrete sequences with a
built-in complexity dial – the bond dimension – and two properties classical mixtures lack:
its marginals and conditionals are exact by contraction (no sampling), and its entanglement
entropy at any cut is a direct, measured receipt of how much long-range correlation the model
carries (bounded by log(bond dimension)).
This module implements a Born-machine MPS over length-L sequences of a d-symbol alphabet:
p(x) proportional to |psi(x)|^2 where psi(x) is the contraction of one matrix per site. It
provides exact normalization / marginals / conditionals by transfer-operator contraction (verified
against brute-force enumeration), the entanglement entropy from the Schmidt spectrum, and
bond-dimension truncation whose error is exactly the discarded Schmidt weight – the receipt the
card asks for (“truncation error tracks the entanglement receipt”).
Scope: this is the exact-conditioning + entanglement-receipt core (the two verification points the card lists first). DMRG fitting and the matched-parameter HMM comparison are follow-ups.
Exploratory mixle.experimental code (P4 card).
- class MPS(tensors)[source]
Bases:
objectA Born-machine matrix-product state: one
(D_left, d, D_right)tensor per site.- probability(x)[source]
Probability of one complete length-
Levent.Use
marginal()for an explicitly partial event; prefixes and extra symbols are rejected.
- marginal(evidence)[source]
p(X_evidence = values)– exact, by contraction over the free sites.
- conditional(query, evidence)[source]
Exact
p(X_query = . | evidence)as a length-dvector.
- random_mps(length, bond, *, d=2, seed=0)[source]
A random Born-machine MPS with open boundaries and interior bond dimension
bond.
- product_mps(site_amplitudes)[source]
A bond-1 product state from per-site amplitude vectors (zero entanglement).
- schmidt_values(mps, cut)[source]
Normalized Schmidt coefficients of the wavefunction at the bond after site
cut-1.
- entanglement_entropy(mps, cut)[source]
Von Neumann entanglement entropy (nats) across the cut – the long-range-structure receipt.
- truncate_error(mps, cut, chi)[source]
Truncate the wavefunction to bond
chiatcut; return (discarded_weight, tv_distance).discarded_weightis the Schmidt weight thrown away (Eckart-Young);tv_distanceis the total-variation distance between the full and truncated probability distributions. Aschishrinks the discarded weight grows and the distribution error grows with it.