
The CHSH Bell Test: Measuring Quantum Correlations with Four Settings
CHSH turns four measurement correlations into a test of a classical bound. A NumPy example calculates the ideal quantum value for a Bell pair.
An entangled pair can produce correlations that no local classical model can reproduce, but how do we quantify that claim? The CHSH Bell test turns it into a calculation with four pairs of measurement settings and one score.
Four settings, four correlations
Imagine two separated observers, Alice and Bob. Alice chooses setting A0 or A1. Bob chooses B0 or B1. Each measurement returns either +1 or -1. For a chosen pair of settings, E(Ai,Bj) is the average product of their outcomes across many trials.
The CHSH score combines the four correlations:
S = E(A0,B0) + E(A0,B1) + E(A1,B0) - E(A1,B1)
Any local hidden-variable model gives |S| ≤ 2, provided the measurement settings are independent of the hidden variables and the observers cannot communicate during a trial. This is the classical bound. Quantum mechanics allows a larger value, up to 2√2.
A Bell pair reaches the quantum limit
Take the Bell state |Φ+> = (|00> + |11>)/√2. Let Alice measure Z for A0 and X for A1. Let Bob measure (Z + X)/√2 for B0 and (Z - X)/√2 for B1. Here X and Z are Pauli operators, and each setting corresponds to a valid measurement with outcomes +1 or -1.
For this state, the four ideal correlations are +1/√2, +1/√2, +1/√2, and -1/√2. Substituting them into the CHSH expression gives S = 2√2, approximately 2.828. That exceeds the local classical limit of 2 and is the maximum quantum value for this test.
Calculate the ideal score with NumPy
This small program evaluates expectation values directly. It uses the basis order |00>, |01>, |10>, |11>, with Alice as the first tensor factor and Bob as the second. It calculates theoretical averages, not finite-shot measurement counts.
import numpy as np
X = np.array([[0, 1], [1, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)
phi_plus = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2)
def correlation(a, b):
value = np.vdot(phi_plus, np.kron(a, b) @ phi_plus)
return float(np.real(value))
A0, A1 = Z, X
B0 = (Z + X) / np.sqrt(2)
B1 = (Z - X) / np.sqrt(2)
E00 = correlation(A0, B0)
E01 = correlation(A0, B1)
E10 = correlation(A1, B0)
E11 = correlation(A1, B1)
S = E00 + E01 + E10 - E11
print([round(e, 3) for e in (E00, E01, E10, E11)])
print(round(S, 3))
Expected output:
[0.707, 0.707, 0.707, -0.707]
2.828
In an experiment, each correlation is estimated from repeated trials for that setting pair, so finite data fluctuates around these ideal values. A calculation like this illustrates the quantum prediction, but it is not by itself a loophole-free Bell test. Real experiments also need careful control of setting choices, communication, and detector losses.
The useful lesson is that entanglement is not just a visual link between two qubits. The pattern across several measurements carries a quantitative signature, and CHSH packages that signature into a number that can be compared with a clear classical limit.