-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodds.py
34 lines (28 loc) · 868 Bytes
/
odds.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
# Online Python compiler (interpreter) to run Python online.
# Write Python 3 code in this online editor and run it.
import random
NUMSIMS = 10000
def sim_match(odds):
return random.randint(0, 1000) < odds * 10
def get_odds(matches):
# print("avg", sum(matches) / 100)
return sum(matches) / 100
"""
res = []
for i in range(NUMSIMS):
tournament = []
for match in matches:
tournament.append(sim_match(match))
res.append(tournament)
counts = [0 for i in range(len(matches) + 1)]
for tournament in res:
counts[tournament.count(True)] += 1
odds = [count / NUMSIMS * 100 for count in counts]
winSum = 0
total = 0
for num, odd in enumerate(odds):
winSum += num * odd
total += odd
# print(f"{sum / total:.2f} average wins")
return winSum / total
"""