Advertisement
Guest User

births

a guest
Jan 1st, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. #!/usr/bin/python
  2. ### converges to 1 as the number of families goes up
  3. families = 1000000
  4. import random
  5. m=1.0
  6. f=1.0
  7. for i in range(families):
  8.     s=0
  9.     while not s:
  10.         if random.random()<0.5:
  11.             m+=1
  12.             s=1
  13.         else:
  14.             f+=1
  15. print 'm:', m,' f:',f,' prop:',m/f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement