import random
def choice_equel(seq, p):
p = list(p)
for i in range(len(p) - 1):
p[i+1] = p[i+1] + p[i]
rnd = random.random()
for index, value in enumerate(p):
if rnd <= value:
return index
if __name__ == '__main__':
system = [
'SMALL',
'MEDIUM',
'LARGE'
]
stats = [0,0,0]
for i in xrange(1000000):
index = choice_equel(system, (0.3, 0.5, 0.2))
stats[index] = stats[index] + 1
print stats