Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Not-firstbornness vs. number of siblings
from scipy.stats import pearsonr
from random import choice
def experiment(max_family_size, trials_per_family_size):
number_of_sibs = []
not_firstborn = []
for num_sibs in range(1,max_family_size+1):
for subject in range(trials_per_family_size):
birthrank = choice(range(num_sibs))
number_of_sibs.append(num_sibs)
if birthrank == 0:
not_firstborn.append(0)
else:
not_firstborn.append(1)
return pearsonr(number_of_sibs, not_firstborn)
for i in range(2,51):
print i, experiment(i,10000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment