Skip to content

Instantly share code, notes, and snippets.

@gallir
Created December 28, 2015 17:49
Show Gist options
  • Save gallir/ffad885419ccccb579c7 to your computer and use it in GitHub Desktop.
Save gallir/ffad885419ccccb579c7 to your computer and use it in GitHub Desktop.
Como https://gist.github.com/gallir/ca8d6cb958bd7767938f pero el sesgo de cada persona cambia con cada elección
#! /usr/bin/env python
import numpy.random as npr
SIZE=3030
LOOP=1000000
TIE=SIZE/2
ties=0
for i in range(1, LOOP):
# Each person has a bias that changes in every poll
individual_bias = npr.randint(100000, size=SIZE)
r = npr.randint(100000, size=SIZE)
# The uniformed distributed random is combined wth the individual bias
a = [1 if x > individual_bias[j] else 0 for j, x in enumerate(r)]
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