Skip to content

Instantly share code, notes, and snippets.

@gallir
Created December 28, 2015 17:44
Show Gist options
  • Save gallir/ca8d6cb958bd7767938f to your computer and use it in GitHub Desktop.
Save gallir/ca8d6cb958bd7767938f to your computer and use it in GitHub Desktop.
Como https://gist.github.com/gallir/18f1adea5bd5c628813d pero cada persona tiene un sesgo que afecta a su elección
#! /usr/bin/env python
""" Execute it several times to vary the biases,
which can be biased too
"""
import numpy.random as npr
SIZE=3030
LOOP=1000000
TIE=SIZE/2
ties=0
# Each person has a given bias
individual_bias = npr.randint(100000, size=SIZE)
print individual_bias
for i in range(1, LOOP):
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