qics.quantum.random.density_matrix

qics.quantum.random.density_matrix(n, iscomplex=False)[source]

Generate a random density matrix, i.e., positive semidefinite matrix \(X\in\mathbb{H}^n\) satisfying \(\text{tr}[X] = 1\), uniformly on the on the Haar measure.

Parameters:
nint

Dimension of random density matrix \(X\).

iscomplexbool, optional

Whether the matrix is real (False) or complex (True). The default is False.

Returns:
ndarray

Random density matrix of dimension (n, n).