Created
October 16, 2022 05:36
-
-
Save galenseilis/acafeb29fa6ca0334228b6efad9a2334 to your computer and use it in GitHub Desktop.
This file contains 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
import matplotlib.gridspec as gridspec | |
import matplotlib.pyplot as plt | |
import numpy as np | |
gs = gridspec.GridSpec(4, 4) | |
x = np.random.randint(1,7,size=10**5) | |
n, c = np.unique(x, return_counts=True) | |
ax1 = plt.subplot(gs[:2, :2]) | |
ax1.bar(n, c) | |
ax1.set_title('Rolling one die') | |
ax1.set_xlabel('Total') | |
ax1.set_ylabel('Frequency') | |
x = np.random.randint(1,7,size=10**5 * 2).reshape(10**5, 2) | |
x = np.sum(x, axis=1) | |
n, c = np.unique(x, return_counts=True) | |
ax2 = plt.subplot(gs[:2, 2:]) | |
ax2.bar(n, c) | |
ax2.set_title('Rolling two dice') | |
ax2.set_xlabel('Total') | |
ax2.set_ylabel('Frequency') | |
x = np.random.randint(1,7,size=10**5 * 100).reshape(10**5, 100) | |
x = np.sum(x, axis=1) | |
n, c = np.unique(x, return_counts=True) | |
ax3 = plt.subplot(gs[2:4, 1:3]) | |
ax3.plot(n, c) | |
ax3.set_title('Rolling one hundred dice') | |
ax3.set_xlabel('Total') | |
ax3.set_ylabel('Frequency') | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment