Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version


random_density_matrix(dims, rank=None, method='Hilbert-Schmidt', seed=None)

GitHub(opens in a new tab)

Generator a random DensityMatrix.


  • dims (int or tuple) – the dimensions of the DensityMatrix.
  • rank (int or None) – Optional, the rank of the density matrix. The default value is full-rank.
  • method (string) – Optional. The method to use. ‘Hilbert-Schmidt’: (Default) sample from the Hilbert-Schmidt metric. ‘Bures’: sample from the Bures metric.
  • seed (int or np.random.Generator) – Optional. Set a fixed seed or generator for RNG.


the random density matrix.

Return type



QiskitError – if the method is not valid.

Was this page helpful?
Report a bug or request content on GitHub.