Skip to content

dq.random.ket

ket(key: PRNGKeyArray, shape: tuple[int, ...]) -> QArray

Returns a random ket with unit norm.

Parameters

  • key –

    A PRNG key used as the random key.

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

    Shape of the returned qarray.

Returns

(qarray of shape (*shape)) Random ket.

Examples

>>> key = jax.random.PRNGKey(42)
>>> dq.random.ket(key, (2, 1))
QArray: shape=(2, 1), dims=(2,), dtype=complex64, layout=dense
[[-0.004+0.083j]
 [-0.26 +0.962j]]