Skip to content

Instantly share code, notes, and snippets.

Created January 14, 2015 07:20
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 anonymous/8a484a7c0be9d14a178b to your computer and use it in GitHub Desktop.
Save anonymous/8a484a7c0be9d14a178b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import random
n_males = 20000
n_females = 1000
mu, sigma = 0.0, 1.0
random.normalvariate(mu, sigma)
males = [(random.normalvariate(mu, sigma), 'm') for i in range(n_males)]
females = [(random.normalvariate(mu, sigma), 'w') for i in range(n_females)]
population = males + females
population.sort(reverse=True) # by descending score, then (w/m)
best1000 = population[:1001]
top1000_males = sum([1 for (score, sex) in best1000 if sex is 'm'])
top1000_females = sum([1 for (score, sex) in best1000 if sex is 'w'])
print "top 1000 (m): %s" % top1000_males
print "top 1000 (w): %s" % top1000_females
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment