Last active
December 28, 2015 17:35
-
-
Save gallir/18f1adea5bd5c628813d to your computer and use it in GitHub Desktop.
Calcula la probabilidad de empate en una votación como la de la CUP simulando resultados
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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