Skip to content

Instantly share code, notes, and snippets.

@willzeng
Created November 5, 2019 17:52
Show Gist options
  • Select an option

  • Save willzeng/4fee8a2f52e7db3429a77305d048b5cb to your computer and use it in GitHub Desktop.

Select an option

Save willzeng/4fee8a2f52e7db3429a77305d048b5cb to your computer and use it in GitHub Desktop.
rand_bitstrings = random_bitstrings(n_qubits, 10_000)
yspace = xspace*(dim**2)*np.exp(-dim*xspace)
# plot both empirical and theoretical calculations
plt.figure(figsize=(9, 6))
plt.hist(rand_bitstrings, bins=50, density=True, label='Empirical')
plt.plot(xspace, yspace, label='Theoretical')
# plot the uniform distribution for reference
plt.axvline(x=1/dim, linestyle='dotted', color='r', label='Uniform Distribution')
plt.xlabel("Probability p")
plt.ylabel("Probability that the random bistring occurs with probability p")
plt.legend(loc='best')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment