Skip to content

Instantly share code, notes, and snippets.

@gallir
Last active December 28, 2015 17:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gallir/18f1adea5bd5c628813d to your computer and use it in GitHub Desktop.
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
#! /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