Skip to content

Instantly share code, notes, and snippets.

@Veticus
Last active September 10, 2023 13:31
Show Gist options
  • Save Veticus/dbfc03fa575ebf4f7541cc0202e74f35 to your computer and use it in GitHub Desktop.
Save Veticus/dbfc03fa575ebf4f7541cc0202e74f35 to your computer and use it in GitHub Desktop.
distribution of numbers by first digit, from 1.6 milion randomly generated numbers
import numpy as np
import matplotlib.pyplot as plt
dist_nums = [834109, 193930, 83203, 83448, 83712, 83123, 83335, 83304, 83044]
rangenums = [i for i in range(1, 10)]
dist_vals = list(zip(rangenums, dist_nums))
labels, values = zip(*dist_vals)
indexes = np.arange(len(labels))
width = 1
plt.bar(indexes, values, width)
plt.xticks(indexes + width * 0.5, labels)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment