Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2013 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7790510 to your computer and use it in GitHub Desktop.
Save anonymous/7790510 to your computer and use it in GitHub Desktop.
If your descendants alternated marrying someone completely of $ethnicity and someone not, they would approach 1/3
fraction_ethnic = 0.0
for generation in range(20):
spouse_ethnic = generation % 2
child_ethnic = (fraction_ethnic + spouse_ethnic) / 2.0
print (
'Generation %d: Parents %.3f%% and %d%% ethnic had a child %.3f%% ethnic' %
(generation, fraction_ethnic*100, spouse_ethnic*100, child_ethnic*100)
)
fraction_ethnic = child_ethnic
Generation 0: Parents 0.000% and 0% ethnic had a child 0.000% ethnic
Generation 1: Parents 0.000% and 100% ethnic had a child 50.000% ethnic
Generation 2: Parents 50.000% and 0% ethnic had a child 25.000% ethnic
Generation 3: Parents 25.000% and 100% ethnic had a child 62.500% ethnic
Generation 4: Parents 62.500% and 0% ethnic had a child 31.250% ethnic
Generation 5: Parents 31.250% and 100% ethnic had a child 65.625% ethnic
Generation 6: Parents 65.625% and 0% ethnic had a child 32.812% ethnic
Generation 7: Parents 32.812% and 100% ethnic had a child 66.406% ethnic
Generation 8: Parents 66.406% and 0% ethnic had a child 33.203% ethnic
Generation 9: Parents 33.203% and 100% ethnic had a child 66.602% ethnic
Generation 10: Parents 66.602% and 0% ethnic had a child 33.301% ethnic
Generation 11: Parents 33.301% and 100% ethnic had a child 66.650% ethnic
Generation 12: Parents 66.650% and 0% ethnic had a child 33.325% ethnic
Generation 13: Parents 33.325% and 100% ethnic had a child 66.663% ethnic
Generation 14: Parents 66.663% and 0% ethnic had a child 33.331% ethnic
Generation 15: Parents 33.331% and 100% ethnic had a child 66.666% ethnic
Generation 16: Parents 66.666% and 0% ethnic had a child 33.333% ethnic
Generation 17: Parents 33.333% and 100% ethnic had a child 66.666% ethnic
Generation 18: Parents 66.666% and 0% ethnic had a child 33.333% ethnic
Generation 19: Parents 33.333% and 100% ethnic had a child 66.667% ethnic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment