-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed the random unitary generation from the Haar measure (#760) #760
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ikkoham than you very much! Can you add a line to the CHANGELOG.md
, under the UNRELEASED > Fixed
section telling what are you fixing, please?
Thanks, I updated changelog.rst. |
It seems the import math
import numpy as np
import scipy.linalg as la
def haar_unitary(n):
z = (np.random.randn(n,n) + 1j*np.random.randn(n,n))/math.sqrt(2.0)
q,r = la.qr(z)
d = np.diagonal(r)
ph = d/np.abs(d)
q = np.multiply(q,ph,q) #This line is missing in the SciPy version.
return q |
Thank you. Does the following line correspond to the last step? |
I think they are the same. I'm going to merge with |
Ahh, yes it does. Good catch. This is good. |
Qiskit#760) * fix Qiskit#519 use scipy.stats.unitary_group * Update CHANGELOG
Summary
To generate random unitary matrix from a Haar measure, I used scipy.stats.unitary_group.
Fix #519