Skip to content

Instantly share code, notes, and snippets.

@zackmdavis
Created December 5, 2011 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackmdavis/1432280 to your computer and use it in GitHub Desktop.
Save zackmdavis/1432280 to your computer and use it in GitHub Desktop.
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