Skip to content

Instantly share code, notes, and snippets.

@sgodfrey66
Created March 11, 2019 19:44
Show Gist options
  • Save sgodfrey66/b854bfeacb154024bba63d4456578028 to your computer and use it in GitHub Desktop.
Save sgodfrey66/b854bfeacb154024bba63d4456578028 to your computer and use it in GitHub Desktop.
# Import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
# Pick a seed for the random number generator
np.random.seed(101)
# Generate random integers between 1 and 6 for a sample size of 10
n_sims = 10
print(np.random.randint(1, 7, n_sims))
# Generate random integers between 1 and 6 for a sample size of 10000
n_sims = 10_000
x = np.random.randint(1, 7, n_sims)
# Plot the histogram
sns.distplot(x, kde = False)
plt.title("Histogram of simulated dice rolls")
plt.xlim([0,7]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment