Create a gist now

Instantly share code, notes, and snippets.

@gallir /ties.py
Last active Dec 28, 2015

What would you like to do?
Calcula la probabilidad de empate en una votación como la de la CUP simulando resultados
#! /usr/bin/env python
import numpy.random as npr
SIZE=3030
LOOPS=1000000
TIE=SIZE/2
ties=0
for i in range(1, LOOPS):
a = npr.randint(2, size=SIZE)
if sum(a) == TIE:
ties += 1
if i % 1000 == 0:
print("Total: {} ties: {} prob: {}".format(i, ties, ties/float(i)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment