Skip to content

dq.rand_dm

rand_dm(key: PRNGKeyArray, shape: tuple[int, ...]) -> Array

Returns a random density matrix (hermitian, positive semi-definite, and unit trace).

Parameters

  • key

    A PRNG key used as the random key.

  • shape (shape of the form (..., n, n))

    Shape of the returned array.

Returns

(array of shape (*shape)) Random density matrix.

Examples

>>> key = jax.random.PRNGKey(42)
>>> dq.rand_dm(key, (2, 2))
Array([[0.576+0.j   , 0.293+0.166j],
       [0.293-0.166j, 0.424+0.j   ]], dtype=complex64)