def _unitary_haar(dim, randstate=None):
"""Returns a sample from the Haar measure of the unitary group of given
dimension.
:param int dim: Dimension
:param randn: Function to create real N(0,1) distributed random variables.
It should take the shape of the output as numpy.random.randn does
(default: numpy.random.randn)
"""
z = _zrandn((dim, dim), randstate) / np.sqrt(2.0)
q, r = qr(z)
d = np.diagonal(r)
ph = d / np.abs(d)
return q * ph
评论列表
文章目录