Random Sampling#
Our package provides samplers for random density matrices drawn from the standard ensembles on the space of mixed quantum states. These are useful for benchmarking, statistical studies, and as reference distributions.
All samplers live in the DensityMatrix class and return a batched array of
shape (n_samples, 2**n_qubits, 2**n_qubits):
import jax
from qml_essentials.random_sampling import DensityMatrix
rhos = DensityMatrix.hilbert_schmidt(
n_qubits=2, n_samples=1000, random_key=jax.random.key(1000)
)
Here, n_samples is the number of density matrices to draw and random_key is an optional JAX random key. If not provided, it defaults to jax.random.key(1000).
An overview of the methods and their properties is given in the following table:
| Method | Distribution / measure | Typical properties | Mixed-state tendency | Parameters | Notes / caveats |
|---|---|---|---|---|---|
| Hilbert–Schmidt | Uniform with respect to Hilbert–Schmidt / Frobenius norm | Full-rank almost surely; moderately mixed; Euclidean-uniform in state space | Generic full-rank mixed states; average purity \(\sim 2/d\) for large \(d\) | None beyond dimension \(d\) | Default choice for “uniform” density matrices |
| Bures | Bures measure, induced by Bures distance | Full-rank almost surely; tends to sample states closer to the boundary than Hilbert–Schmidt; more weight on purer states | Mixed but biased toward nearly pure/boundary states; typically purer than Hilbert–Schmidt | None beyond \(d\) | More physically meaningful because Bures distance is related to state distinguishability |
| Induced measure | Induced ensemble with environment dimension \(k\) | Rank \(\leq \min(d,k)\); for \(k<d\), rank-deficient; for \(k\gg d\), concentrated near maximally mixed state | Mixedness tunable by \(k\): \(k=1\) pure, \(k=d\) Hilbert–Schmidt, \(k\gg d\) near maximally mixed | Ancilla/environment dimension \(k\) | Hilbert–Schmidt is the special case \(k=d\). Pure states correspond to \(k=1\) |
| Eigenvalue + eigenvector method | Depends entirely on chosen eigenvalue distribution | Highly flexible; allows to control purity, rank, spectrum | Controllable via eigenvalues; can enforce pure, low-rank, highly mixed, or fixed-purity states | Eigenvalue distribution, e.g. Dirichlet distribution | Sampling eigenvalues uniformly from simplex does not give Hilbert–Schmidt measure; missing eigenvalue-repulsion factors |
Mathematical details and the usage of these methods is detailled in the sections below.
Hilbert-Schmidt#
The Hilbert-Schmidt measure is the flat measure induced by the Hilbert-Schmidt metric. A sample is obtained from a square \(d \times d\) complex Ginibre matrix \(G\) (with \(d = 2^{n_\text{qubits}}\)) via
The (complex) Ginibre matrix is a random matrix whose entries are independent Gaussian random variables, s.t. \(\mathbb{E}\left[\left|G_{i j}\right|^{2}\right]=1\).
Induced#
The induced measure \(\mu_{d,K}\) generalizes the Hilbert-Schmidt measure by letting the Ginibre matrix \(G\) be rectangular, of shape \(d \times K\), where \(K\) is the rank parameter:
The sampled state has rank \(\min(d, K)\) almost surely. \(K = d\) recovers the Hilbert-Schmidt measure, while \(K = 1\) yields (Haar-random) pure states. The mean purity is \(\mathbb{E}[\mathrm{Tr}\,\rho^2] = (d + K)/(dK + 1)\).
# Low-rank (more mixed) sampling with K = 2
rhos = DensityMatrix.induced(
n_qubits=2, n_samples=1000, rank=2, random_key=jax.random.key(1000)
)
This measure is described in Zyczkowski & Sommers (2000) - Induced measures in the space of mixed quantum states.
Bures#
The Bures measure is induced by the Bures (statistical-distance) metric and is a natural prior of minimal information. A sample combines a Ginibre matrix \(G\) with an independently drawn Haar-random unitary \(U\):
The construction and its mean purity \(\mathbb{E}[\mathrm{Tr}\,\rho^2] = (5d^2 + 1)/(2d(d^2 + 2))\) are given in Osipov, Sommers & Zyczkowski (2009) - Random Bures mixed states and the distribution of their purity and Sommers & Zyczkowski (2003) - Bures volume of the set of mixed quantum states.
Eigenvalue Sampling#
This method builds a density matrix from a Haar-random eigenbasis \(U\) and a chosen spectrum \(\lambda\):
By default, the eigenvalues are drawn from a symmetric Dirichlet distribution \(\lambda \sim \mathrm{Dir}(\alpha \mathbf{1}_d)\), where \(\alpha = 1\) corresponds to the uniform (flat) distribution on the probability simplex:
rhos = DensityMatrix.eigen(
n_qubits=2, n_samples=1000, alpha=1.0, random_key=jax.random.key(1000)
)
Note that, by construction, this ensemble differs from the Hilbert-Schmidt and induced measures: it lacks their eigenvalue repulsion.
Alternatively, a fixed spectrum can be supplied via eigenvalues (a nonnegative vector of length \(d\) summing to 1). The same spectrum is then used for every sample and only the eigenbasis \(U\) is randomized: