Created
December 28, 2015 17:49
-
-
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
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 | |
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