-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNo trading.py
70 lines (51 loc) · 1.78 KB
/
No trading.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import random
import seaborn as sns
import statistics
#Set variables
count_rounds = []
count = 0
#start 1000 simulations
for i in range(0,1000):
#A count to keep track de simulations
count += 1
#Create the "album" using a dictionary
total_album = {}
for i in range(0,634):
total_album[i]= 0
#Set variables
rounds = 0
count_missing = {}
#Star iteration until the album is full
while True:
rounds += 1
missing = 0
#Creates random stiker
sticker = random.randint(0,633)
#Adds that sticker to de dict
total_album[sticker] += 1
#checks how many "stickers" are missing to complete the album
for i in total_album:
if total_album[i] == 0:
missing += 1
#If theres no more sticker missing, the loop stops
if missing == 0:
break
#"Count_missing" is a dict that keeps track of the amount of iterations that were made in order to get a new sticker
try:
count_missing[missing] += 1
except:
count_missing[missing] = 0
if count_missing[missing] == 0:
count_missing[missing] += 1
#The amount of iterations made is stored into a list to analyze later
count_rounds.append(rounds)
#To keep track of simulations
print(f"{count}/1000")
#Generation of histogram
sns.set(style = "white")
p = sns.histplot(data=count_rounds, binwidth = 100, kde = True)
p.set_xlabel("Amount of Stickers")
p.set_ylabel("")
#Print mean and standard deviation
print(statistics.pstdev(count_rounds))
print(sum(count_rounds)/len(count_rounds))