ZPP
ZPP
  • Threads: 2
  • Posts: 31
Joined: Feb 7, 2010
May 21st, 2019 at 1:10:12 AM permalink
Rambling preamble: This may be a duplicate thread. In this video, the Wizard says that there is a forum discussion about calculating the probability of at least 5 people out of n sharing a birthday, and that Mathematica calculates loops more efficiently than C++. I can't find the thread. However, I suspect that entirely different algorithms are being used in Mathematica and C++. I have a reasonably efficient solution in C++, and I was going to write up a post about it today, but as chance would have it, I saw and responded to this post instead. So instead, I'll throw it open, and post my solution this weekend (but the table below is reasonable evidence that I already have a solution).

Problem:

It is commonly known that a group of 23 people has a 50.7% chance that at least 2 people share a birthday. (Assuming, as one does in these problems, that birthdays are drawn independently and uniformly at random from the 365 days that are not Feb 29.)

Define the "k-birthday problem" as finding the least n such that, in a group of n people, the probability that at least k people share a birthday is at least 50% (with the same random birthday assumption).

How do you efficiently solve this problem, using a computer? (for cases where n ends up being in the thousands, but not much larger, let's say)

Efficiency is vague, but the following should be computable on a modern computer in much less than 30 seconds:
knprobability that at least k out of n share birthday
2230.507297234323985
3880.511065110624731
41870.502685373188976
53130.50107047584923
64600.502449410369367
76230.502948948664597
87980.500320275210473
99850.500948416381688
1011810.500931161054311


Bonus points for clear explanations and simple but efficient solutions. An arbitrary-precision arithmetic library might be helpful -- I used one to get large exact counts that I converted to the probabilities above -- but it is also possible to solve with floating-point arithmetic and minor rounding error.
7craps
7craps
  • Threads: 18
  • Posts: 1977
Joined: Jan 23, 2010
May 21st, 2019 at 9:08:43 AM permalink
Quote: ZPP

Rambling preamble: This may be a duplicate thread. In this video, the Wizard says that there is a forum discussion about calculating the probability of at least 5 people out of n sharing a birthday, and that Mathematica calculates loops more efficiently than C++. I can't find the thread.

it hijacked another thread

https://wizardofvegas.com/forum/gambling/tables/32745-roulette-16-number-board-history/3/#post709423

the original code was in Mathematica, I do remember that, (I think over at math.stackexchange.com) but that seems to have been removed as that author converted that into R (do not know or remember why) and only that remains.

I have not looked back at that.
good luck
thank you for sharing some of your great computer code and math results in the past.
winsome johnny (not Win some johnny)
  • Jump to: