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]:
- 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.
Perform a QR decomposition of this matrix, obtaining a unitary and upper triangular matrices.
- 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.