Hacker News new | past | comments | ask | show | jobs | submit login

It's fun to reason these things out, but it's easier and faster to simulate, at least at first.

  import random, time, collections, pprint
  
  sample = collections.defaultdict(float)
  
  now = time.time()
  
  known_child = ('M', 2)
  
  while sum(sample.values()) < 100000:
      genders = [random.choice('MF') for dummy in '..']
      birthtimes = [random.uniform(0, now) for dummy in '..']
      birthdays = [time.localtime(t).tm_wday for t in birthtimes]
      gendertimes = zip(genders, birthdays)
      if known_child in gendertimes:
          gendertimes.remove(known_child)
          sample[gendertimes[0]] += 1
          if (sum(sample.values()) % 10000) == 0:
              print sum(sample.values())
  
  males,females = [sum(c for (g, t), c in sample.items() if g == gender)
                   for gender in 'MF']
  
  print males / (males + females)
Result when I ran this was .4816, approximately equal to 13/27.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: