iqm.pulse.gates.u.get_haar_random_unitary

iqm.pulse.gates.u.get_haar_random_unitary#

iqm.pulse.gates.u.get_haar_random_unitary(d=2, rng=None)#

Generates a random unitary matrix drawn uniformly from Haar measure.

Follows the procedure outlined in [2]:

  1. Generate a n x n matrix of complex numbers such that both real and imaginary parts of each number are drawn

    independently from a normal distribution with mean 0 and variance 1.

  2. Perform a QR decomposition of this matrix, obtaining a unitary and upper triangular matrices.

  3. Normalize the unitary, multiplying each column by the sign of a corresponding diagonal entry in the upper

    triangular matrix, which are guaranteed to be real.

The last step is necessary, because otherwise the non-uniqueness of the QR decomposition introduces bias to the sampling process.

Parameters:
  • d (int) – Dimension of the generated unitary.

  • rng (Generator | None) – Random number generator object.

Returns:

A random unitary matrix of requested dimension.

Return type:

ndarray