Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created July 16, 2020 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaraM92/2e47bfff3e049f37d41d266d9da5de0f to your computer and use it in GitHub Desktop.
Save SaraM92/2e47bfff3e049f37d41d266d9da5de0f to your computer and use it in GitHub Desktop.
from random import randint
from collections import Counter
#A function to genrate randome experiments
def gen(x):
expResults = []
for i in range(x):
expResults.append(randint(1,6))
return expResults
#An experiment with 100 events
event1 = dict(Counter(gen(100)))
for k,v in event1.items():
print("probability of", k, "is",v/100)
print("------------------------------")
#An experiment with 1000 events
event2 = dict(Counter(gen(1000)))
for k,v in event2.items():
print("probability of", k, "is",v/1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment