Last active
November 6, 2019 04:35
-
-
Save willzeng/1fa2fcebf3152c1caa84895dd7a7cdc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def random_bitstrings(n_qubits, n_programs): | |
| dim = 2**n_qubits | |
| # keep track of probability of sampling (randomly) chosen bitstring | |
| probs_bitstring = [] | |
| # simulate many Haar-random circuits | |
| for _ in range(n_programs): | |
| unitary = random_unitary(dim) | |
| bitstring = np.random.choice(dim, p=[np.abs(unitary[b,0])**2 for b in range(dim)]) | |
| prob = np.abs(unitary[bitstring,0])**2 | |
| probs_bitstring.append(prob) | |
| return probs_bitstring |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment