Created
July 23, 2021 14:20
-
-
Save matagat/4e3b493dbf1baf0b3545089b51630920 to your computer and use it in GitHub Desktop.
Reddit post sc
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
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import math | |
| p = np.array([0,0,0,0,0,0]) | |
| means = np.array([1000]) # <- ?? | |
| sum = 0; | |
| for x in range(1000): | |
| s = np.random.default_rng().uniform(1,7,1) | |
| sum = sum + math.floor(s) | |
| #print(math.floor(s)) | |
| if(math.floor(s) == 1): # If the die rolls 1 | |
| p[0] = p[0] + 1 | |
| if(math.floor(s) == 2): # If the die rolls 2 | |
| p[1] = p[1] + 1 | |
| if(math.floor(s) == 3): # If the die rolls 3 | |
| p[2] = p[2] + 1 | |
| if(math.floor(s) == 4): # If the die rolls 4 | |
| p[3] = p[3] + 1 | |
| if(math.floor(s) == 5): # If the die rolls 5 | |
| p[4] = p[4] + 1 | |
| if(math.floor(s) == 6): # If the die rolls 6 | |
| p[5] = p[5] + 1 | |
| print("1's Rolled:",p[0]) | |
| print("2's Rolled:",p[1]) | |
| print("3's Rolled:",p[2]) | |
| print("4's Rolled:",p[3]) | |
| print("5's Rolled:",p[4]) | |
| print("6's Rolled:",p[5]) | |
| mean = sum/1000 | |
| print("Mean: ",mean) | |
| plt.hist(mean); | |
| print(means) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment