Last active
June 8, 2016 18:35
-
-
Save maxhodak/6c7e803c195dd71a573469904eb6c4ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from __future__ import division | |
import random | |
# question: consider a society that allows only a single child, | |
# unless your first child is a girl, in which case you can have | |
# one more child. does this policy introduce a male gender bias? | |
N = 1000 | |
boys = 0 | |
for _ in xrange(N): | |
if random.randint(0, 1) > 0: # is a boy | |
boys = boys + 1 | |
else: # first child is a girl | |
N = N + 1 | |
boys = boys + random.randint(0, 1) | |
print("Boys: %d, Girls: %d" % (boys, N - boys)) | |
# => Boys: 732, Girls: 268 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment