To average a quantity over random unitaries we first need a sensible notion of what random means on the group, and that is supplied by a measure that weighs subsets of the group. The natural choice is the one that does not change when the group acts on itself by multiplication, called the Haar measure. Invariance under this action is exactly what makes an average meaningful, since it guarantees that relabeling by any fixed unitary leaves the average untouched. On a compact group this invariant measure exists and is unique once the total weight is fixed to one.
The simplest instance is the circle group \(U(1)\), whose elements are phases \(e^{i\theta}\). Here the Haar measure is the uniform density \(d\theta/(2\pi)\), and one can see why invariance forces this form. A density on the circle expands in Fourier modes, and rotating the circle multiplies every nonzero mode by a phase. For the density to come back to itself under all rotations, those modes have to vanish, which leaves only the constant term that normalization then sets.
The same argument reaches into higher dimensions through the determinant. If \(U\) is drawn from the Haar measure on \(U(D)\), multiplying it by a global phase rotates \(\det U\) around the unit circle, and Haar invariance says this rotation cannot change the distribution. The phase of the determinant is therefore forced to be uniform, a simple signature of Haar randomness that persists in any dimension.
The notebook samples random unitaries and compares the distribution of the determinant phase against the uniform law.
Mathematical background
On the full group \(U(D)\) the defining property is invariance under multiplication from either side,
Because \(U(D)\) is compact, this measure exists, is unique, and can be normalized to \(\int_{U(D)} d\mu(U) = 1\). Left invariance is what guarantees that a Haar-random unitary applied to any fixed reference state produces a state \(|\psi\rangle = U|\psi_0\rangle\) whose distribution is the uniform measure on the sphere \(S^{2D-1}\), independent of \(|\psi_0\rangle\). A concrete way to sample is to draw a complex Ginibre matrix \(G\) with independent Gaussian entries and take the \(Q\) factor of its QR decomposition, with the diagonal phases of \(R\) fixed so that the result is uniform. The \(U(1)\) case worked out in this notebook is the smallest instance of the same invariance argument, with the uniform phase density \(d\theta/(2\pi)\) as its unique solution.
Motivation
The Haar measure is the unique translation-invariant probability measure on a compact Lie group. Its existence and uniqueness underpin every Haar-random construction in this book, from random matrix theory to unitary designs. The circle group \(U(1)\) is the simplest compact Lie group and provides the clearest illustration of these concepts: uniqueness follows from a Fourier analysis argument, and the connection to determinant phases generalizes directly to \(U(D)\).
Exercise
The circle group \(U(1) = \{e^{i\theta} : \theta \in [0, 2\pi)\}\) has Haar measure \(d\mu = d\theta/(2\pi)\).
(b) Prove uniqueness: any continuous translation-invariant density \(p(\theta)\) must equal \(1/(2\pi)\).
(c) For Haar-random \(U \in U(D)\), show that the phase of \(\det(U)\) is uniformly distributed on \([0, 2\pi)\).
Solution
Part (a): Translation invariance
Under the substitution \(\theta' = \theta + \alpha\), \(d\theta' = d\theta\), and the domain \([0, 2\pi)\) maps to \([\alpha, 2\pi + \alpha)\). Since the integrand \(f(e^{i\theta'})\) is \(2\pi\)-periodic in \(\theta'\), the integral over any interval of length \(2\pi\) is the same:
Translation invariance requires \(\int f(\theta + \alpha)\, p(\theta)\, d\theta = \int f(\theta)\, p(\theta)\, d\theta\) for all \(\alpha\) and all test functions \(f\). This implies:
The Haar measure is the unique translation-invariant measure on \(U(1)\).
Part (c): Determinant phase is uniform
For \(U \in U(D)\), write \(\det(U) = e^{i\Phi}\) where \(\Phi = \sum_k \varphi_k\) is the sum of eigenphases.
Left multiplication \(U \to e^{i\alpha}U\) shifts every eigenphase by \(\alpha\), so \(\det(e^{i\alpha}U) = e^{iD\alpha}\det(U)\). This shifts \(\Phi \to \Phi + D\alpha\).
Since the Haar measure is left-invariant, the distribution of \(\Phi + D\alpha\) equals the distribution of \(\Phi\) for all \(\alpha\). By the uniqueness result of part (b) (applied to the group \(U(1)\) acting on the determinant phase), \(\Phi\) must be uniformly distributed on \([0, 2\pi)\).
Invariance alone pins down the Haar measure on \(U(1)\) as the uniform density \(1/(2\pi)\). The same argument, applied to the determinant, shows that \(\det U\) has uniform phase for Haar-random \(U \in U(D)\).
Code
import numpy as npfrom scipy.stats import unitary_group, kstestnp.random.seed(42)# Verify det(U) phase is uniform for several Dfor D in [2, 4, 8]: phases = []for _ inrange(5000): U = unitary_group.rvs(D) det_phase = np.angle(np.linalg.det(U)) % (2*np.pi) phases.append(det_phase / (2*np.pi)) # normalize to [0,1)# KS test against uniform[0,1] stat, pval = kstest(phases, 'uniform')print(f"D={D}: KS statistic = {stat:.4f}, p-value = {pval:.4f} "f"[{'uniform'if pval >0.01else'REJECT'}]")assert pval >0.01print("\nDeterminant phase is uniform for all D.")
D=8: KS statistic = 0.0171, p-value = 0.1080 [uniform]
Determinant phase is uniform for all D.
References
Mele, Introduction to Haar Measure Tools in Quantum Information: A Beginner’s Tutorial, Quantum (2024). doi
Collins and Śniady, Integration with respect to the Haar measure on unitary, orthogonal and symplectic group, Communications in Mathematical Physics (2006).
Mezzadri, How to generate random matrices from the classical compact groups, Notices of the American Mathematical Society (2007).
Płodzień, Information Scrambling, Quantum Chaos, and Haar-Random States, lecture notes (2025). arXiv:2511.14397