dq.random.dm
dm(key: PRNGKeyArray, shape: tuple[int, ...]) -> QArray
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 qarray.
Returns
(qarray of shape (*shape)) Random density matrix.
Examples
>>> key = jax.random.PRNGKey(42)
>>> dq.random.dm(key, (2, 2))
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dense
[[0.576+0.j 0.293+0.166j]
[0.293-0.166j 0.424+0.j ]]