Notebook 01 · 2026-09-13 · PhysioNet eegmmidb S001 · O1, O2

One Qubit from Two Electrodes

Four seconds of EEG from two occipital electrodes, turned into a mixed quantum state, loaded onto a qubit by purification, and read back. Every number on this page is the real one.

DataPhysioNet eegmmidb, subject S001, run R02 (eyes closed)
ChannelsO1, O2 · 160 Hz
Windowseconds 10–14 · 640 samples per channel
BackendQiskit 2.5 statevector + Aer, 1000 shots

The claim being tested

A trace-normalised covariance matrix is a density matrix. Not by analogy: it is symmetric, positive semidefinite and has trace one, which is the whole definition. So a window of multichannel EEG defines a quantum state, and the question DSP-000 asks is whether that state can be prepared on a register and measured there with the answer a classical computation already knows.

This is the smallest possible instance: two channels, a 2×2 matrix, one qubit. Small enough that every intermediate value fits on the page, and small enough that if any step were wrong it would be obvious.

EEG window2 ch × 640 samples covariance Σ2 × 2, µV² state ρ = Σ / tr Σtrace 1 weights λ, patterns Veigendecomposition 2-qubit circuitsystem + ancilla 1000 shots⟨Z⟩ read back CLASSICAL · SIGNAL SIDE QUANTUM · REGISTER SIDE
The pipeline. Everything left of the circuit is ordinary signal processing; the circuit's only job is to hold the same state the classical side already computed, so the two ends can be compared.
1

The window system

Subject S001 sitting with eyes closed, seconds 10 to 14 of the run. Two electrodes over visual cortex, demeaned, band-passed 0.5–40 Hz, 60 Hz notched. The alpha rhythm is plainly visible on both, and the two traces move together most of the time. That co-movement is the entire content of what follows.

O1O2 10 s12 s14 s +250 µV
The 640 samples per channel that feed the covariance. Vertical scale ±250 µV about each channel's mean.
2

Covariance, then state system

The covariance estimator is Ledoit–Wolf shrinkage (the same lwf used throughout the CHB-MIT work). Diagonals are each channel's variance in µV²; the off-diagonal is how much they co-vary. O2 carries more power than O1 in this window, and the two are strongly correlated (r = 0.76).

Σ (µV²) O1 O2 O1 3590.85 3441.45 O2 3441.45 5698.05 tr Σ = 9288.90

Dividing by the trace throws away one number, the total power, and keeps the shape. What remains is a valid density matrix:

ρ = Σ / tr Σ O1 O2 O1 0.3866 0.3705 O2 0.3705 0.6134 tr ρ = 1.000000

The diagonal of ρ is the fraction of window power on each electrode. The off-diagonal is the coherence between them. In quantum language this is a mixed state — not a single pure vector, but a weighted mixture of two.

3

Weights and patterns system

Diagonalising ρ splits it into two orthogonal spatial patterns and a weight on each. Plotted in the O1–O2 plane, the 640 samples form an elongated cloud; the long axis is the first pattern, and its weight is the fraction of power along it.

ρ = λ0 v0v0⊤ + λ1 v1v1⊤,  λ0 + λ1 = 1
v₀ λ₀ = 0.888 v₁ λ₁ = 0.112 O1 →O2 ↑
Each dot is one sample (O1 on the horizontal axis, O2 vertical, µV). The arrows are the eigenvectors of ρ, scaled by √λ so their lengths show the weight ratio.
weights λ λ₀ = 0.8875 λ₁ = 0.1125 patterns V (columns) v₀ v₁ O1 0.5947 −0.8040 O2 0.8040 0.5947
purity tr ρ²
0.8003
pure = 1, maximally mixed = 0.5
entropy S(ρ)
0.352
nats · max ln 2 = 0.693

Read in EEG terms: 89 % of the window's power is a single in-phase pattern where O2 swings about 1.35× as far as O1, and the remaining 11 % is the anti-phase remainder. The state is mostly, but not entirely, pure. Purity and entropy are two views of the same two numbers, λ0 and λ1.

4

Loading it onto a qubit ancilla

A single qubit on its own is always in a pure state, so a mixed ρ cannot be written onto one directly. Purification is the standard fix: add a second qubit, the ancilla, and build a pure state of the pair whose system half looks like ρ once the ancilla is ignored.

|Ψ⟩ = Σk √λk |vk⟩sys |k⟩anc

The circuit does this in three gates. The ancilla is rotated so its amplitudes are √λ0 and √λ1; a CNOT copies that choice onto the system; then the unitary V rotates the system's basis states into the two patterns.

anc |0⟩ sys |0⟩ Ry(0.684) V set weights √λcopy choicerotate into patterns1000 shots
The purification circuit. θ = 2 arctan(√λ1 / √λ0) = 0.684 rad, so Ry(θ)|0⟩ = √λ0|0⟩ + √λ1|1⟩. V is exactly the pattern matrix from step 3, used as a gate.

The resulting two-qubit statevector, in the basis |anc sys⟩:

basisamplitudemeaning
|0 0⟩+0.5602√λ0 · v0[O1] = 0.942 × 0.595
|0 1⟩+0.7574√λ0 · v0[O2] = 0.942 × 0.804
|1 0⟩−0.2697√λ1 · v1[O1] = 0.335 × (−0.804)
|1 1⟩+0.1995√λ1 · v1[O2] = 0.335 × 0.595

Each amplitude is a weight times a pattern entry — the eigendecomposition written out as a state. The ancilla's bit labels which pattern; the system's bit labels which electrode.

5

Check: is the state actually ρ? system

Trace out the ancilla and compare the reduced system state to the matrix from step 2.

reduced state on the system 0.3866 0.3705 0.3705 0.6134 max |reduced − ρ| = 3.3 × 10⁻¹⁶

Agreement to floating-point precision. The qubit is holding the covariance shape of that four-second window.

6

Read it back shots

The simplest observable on one qubit is Z, with eigenvalue +1 on |0⟩ and −1 on |1⟩. Here |0⟩ is electrode O1 and |1⟩ is O2, so Z asks: which electrode carries more of the power?

⟨Z⟩ = tr(ρZ) = ρ11 − ρ22 = 0.3866 − 0.6134 = −0.2269

Negative means O2. On the register this is estimated by measuring both qubits 1000 times and counting.

6003000 3245547052 |0 0⟩|0 1⟩|1 0⟩|1 1⟩ pattern 0 · O1pattern 0 · O2pattern 1 · O1pattern 1 · O2
Counts over 1000 shots, bit order |anc sys⟩. Teal bars are the ancilla in |0⟩ (first pattern), amber the ancilla in |1⟩ (second pattern). Simulator seed 7.
shot ⟨Z⟩
−0.212
P(sys = 0) − P(sys = 1) = (324 + 70 − 554 − 52) / 1000
exact tr(ρZ)
−0.227
difference 0.015; expected shot noise ≈ 0.031
ancilla in |0⟩
878 / 1000
estimates λ₀ = 0.8875 — the weight, for free

The register agrees with the classical calculation within half a standard error of the shot noise. And the ancilla marginal, which was only there to make the state mixed, reads out the leading eigenvalue on its own: 87.8 % versus the true 88.75 %.

7

Purity, from the ancilla verification

Purity and entropy are not linear in ρ, so they cannot be read the way Z was. The usual route on a register is a SWAP test, which needs two copies of the state. This circuit does not need that, because the ancilla already holds the spectrum.

The reason is the Schmidt decomposition: for any pure state of two registers, the two halves have the same nonzero eigenvalues. The purification put those eigenvalues on the ancilla's diagonal in the measurement basis, so a plain count of the ancilla bit estimates λ0 and λ1 directly, and from them:

tr ρ2 = p02 + p12,  S = −p0 ln p0 − p1 ln p1
ancilla fractions
0.878 / 0.122
from 878 and 122 of 1000 shots
purity from shots
0.786
exact tr ρ² = 0.800
entropy from shots
0.371
exact S = 0.352 nats

Both within shot noise, and the small-count bias on the minor eigenvalue accounts for most of the gap (the 8-channel version of this test, at 20,000 shots, lands on 0.492 against an exact 0.493).

This is a verification, not a circuit design. The ancilla reads the eigenvalues because the preparation loaded them there, and it will keep reading them under any unitary applied to the system afterwards — which also means nothing new is learned that way, since unitaries cannot change a spectrum. The moment the system is coupled to anything else — the open-system E/I channel that this framework is heading toward — the system–ancilla pair is no longer pure, the ancilla stops tracking the system's spectrum, and purity has to be read from the system side. That is where the SWAP test comes back.

What this does and does not show

It shows that the covariance-as-density-matrix identification survives contact with a real register, end to end, with real data: the preparation is exact, and a linear observable read by sampling matches tr(ρO) to within statistical error. The method is purification; nothing in it is specific to two channels, and the same three-gate structure scales to 4 channels (2 system qubits, 2 ancilla) and 8 channels (3 + 3).

It does not show any advantage. A 2×2 matrix is trivial to diagonalise, and the circuit needs the eigendecomposition as input, so the register is holding an answer the classical side already had — including the purity read from the ancilla, which only works because the preparation put the spectrum there. That is the point of a first test, not a defect of it. The experiment that goes beyond verification is to let the system evolve under something non-unitary and read purity from the system side, with a SWAP test or randomised measurements. That was not run here.

What was run here is the floor: the state is real, it can be put on a qubit, the qubit gives it back, and its purity can be checked. The same three-gate structure was then run at 4 channels (2 + 2 qubits, 5 CNOTs) and 8 channels (3 + 3 qubits, 26 CNOTs) with the same result.