ffsim.random.random_density_matrix¶
- ffsim.random.random_density_matrix(dim, *, seed=None, dtype=<class 'complex'>)[source]¶
Returns a random density matrix distributed with Hilbert-Schmidt measure.
A density matrix is positive semi-definite and has trace equal to one.
The Hilbert-Schmidt measure is the measure induced by tracing out one half of a uniformly random pure state on a doubled Hilbert space (see
random_state_vector()). It is the canonical member of the family of induced measures: it is the flat measure on the set of density matrices, and it is invariant under conjugation by any unitary. Ifdtypeis a real type, then the real analog is sampled instead.- Parameters:
dim (
int) – The width and height of the matrix.seed – A seed to initialize the pseudorandom number generator. Should be a valid input to
np.random.default_rng.dtype – The data type to use for the result.
- Return type:
- Returns:
The sampled density matrix.
- Raises:
ValueError – Dimension must be at least one.
References