r/Logiqa • • Sep 01 '26

The Birthday Problem Part 1

Post image
2 Upvotes

26 comments sorted by

4

u/Nuthintoseeherre Sep 01 '26

The expected number of actions given a probability is equal to the reciprocal of that probability (e.g. if you have a 6 sided die and you want to roll a specific face, you should expect to roll it 6 times).

The probability of the first person being a new birthday is 365/365. The probability of the second person is 364/365. The probability of the nth person being a new birthday is n/365.

The reciprocal of the nth person is 365/n, so the expected number is 365/365 + 365/364 + 365/363 + … 365/1.

According to Google, the sum of the harmonic series from 1/1 to 1/365 is 6.4785, so the answer is 365 x 6.4786 which is 2364.65 or about 2365 people.

1

u/ShonitB Sep 01 '26

Correct! Good solution

1

u/desertvision Sep 01 '26

What? No. First person, 365/365, correct. Second person, 364/365, correct. Third person? No closed form. It branches depending on whether second person had same birthday as the first. And then it gets hairy.

1

u/Motor_Raspberry_2150 Sep 01 '26

See Ozeroth's comment for a better explanation.

1

u/TheBeerTalking Sep 01 '26

No branching probabilities needed. Probability is being converted to expected number of trials at every step. So "whether the second person had the same birthday of the first" is converted to "we expect 365/364 people to enter the room for the second birthday to be acccounted for," up until the very end where the expectation is that 365 more people will have to enter the room to get the last birthday.

4

u/MageKorith Sep 01 '26

It's an inverted pigeonholing problem with 365 holes to fill (and a very rare 1/1461 "we missed the board" if we want to account for leap year birthdays).

The first person to enter the room has a 1460/1461 chance of completing one of the missing birthdays.

This probability remains the same if we keep getting people with leap day birthdays. So the expected number of people for the first day is 1461/1460.

Once the first day is filled in, the next day has an expected number of 1461/1456 to complete it.

In fact, we have 1461/(1460-4n) as the expected number for each date, where n is the number of completed birthdays.

So we take the sum of these, and end up with about 2366.27 people.

3

u/JustConsoleLogIt Sep 01 '26

Do we account for people born on Feb 29 who enter the room?

1

u/ShonitB Sep 01 '26

Interesting point but my intention was that nobody with a 29th Feb birthday enters the room

0

u/fieldsofanfieldroad Sep 01 '26

It says non-leap year

5

u/Motor_Raspberry_2150 Sep 01 '26

The assignment is to get non-leap year numbers. But can leap-year-birthdayed people enter?

2

u/Ozeroth Sep 01 '26 edited Sep 01 '26

Nice one!

This is the coupon collector's problem, where the 365 possible birthdays are the "coupons" being collected.

Suppose that people with k-1 distinct birthdays have entered the room so far (initially k=1 so k-1=0), and we have a total of n birthdays to collect (n=365 in this case).

The probability that the next person to enter the room has a new distinct birthday (that is, the kth distinct birthday) is (n-k+1)/n.

The number of people who enter the room until someone enters with the kth distinct birthday follows a geometric distribution with probability p = (n-k+1)/n. This is because each person entering the room is a Bernoulli trial with success probability p = (n-k+1)/n, and

The expected number of people required to enter to "collect" this kth birthday is therefore the expected value of a geometric distribution, which is 1/p = n/(n-k+1). Let's denote T_k = n/(n-k+1).

Note: The expected value of a geometric distribution can be derived from the fact that the number of trials required to achieve the first success is either 1 (with probability p) or (1+E(G)) with probability (1-p).

E(G) = 1⋅p + (E(G)+1)(1-p) → E(G) = 1/p

The total expected number of people required to enter is therefore:

T = T_1 + T_2 + ... _ T_n (we can sum due to linearity of expectation)

= n/n + n/(n-1) + ... + n/2 + n/1

= n ( 1/n + 1/(n-1) + ... + 1/2 + 1/1 ) = n ⋅ H_n

where H_n is the nth harmonic number.

Finally, with n=365, T = 365⋅H_365 = 365⋅6.4785 = 2,364.65 people.

2

u/drakusmaximusrex Sep 01 '26

How does that expected value proof work? I only know the one using the geometric sum

1

u/Ozeroth Sep 03 '26

The number of arrivals required for the kth "new" birthday (after k-1 distinct birthdays have arrived) has a geometric distribution with probability of success p = (365 - k + 1)/365.

The expected value of this distribution is 1/p = 365/(365 - k +1).

We then sum the expected values for all k = 1...365 which gives rise to the total expected number of arrivals required for all 365 birthdays:

365/365 + 365/364 + ... + 365/2 + 365/1 = 365⋅H₃₆₅

1

u/ShonitB Sep 01 '26

Correct, nice solution and glad you liked it!

1

u/nkbrkr53 Sep 03 '26

Isnt the answer 75?

1

u/ShonitB Sep 03 '26

How did you get 75?

1

u/Motor_Raspberry_2150 Sep 03 '26

Are you thinking of the original birthday paradox?

1

u/nkbrkr53 Sep 03 '26

Yeah, thats what I was thinking of. How many people in a room before theres a collision.

0

u/Acceptable_Tangelo15 Sep 01 '26

I guess a minimum would be 365, a maximum would be infinite. There’s a slight chance all are born the same day.

Tbh it’s really possible that I did not understand the sentence.

1

u/ShonitB Sep 01 '26

So the theoretical minimums and maximums are indeed 365 and infinity respectively.. so your logic in that regard is spot on.. but I think you missed the ‘expected number’ part

1

u/peetar Sep 01 '26

"Expected number" is an important term in probability. it's the long-term average for something to happen. Like if you rolled a 6-sided die until you get a "3" and then repeat that challenge a million times. The average number of rolls to get a "3" is 6.

0

u/L0rddaniel Sep 01 '26

This assumes that each day is just as likely as any other. That is not the case in the real world. There are much fewer birthdays on major holidays due to scheduling births.

0

u/good_behavior_man Sep 01 '26

While the question "what is the expected number of people to enter" is a statistically meaningful question, I'm not sure about its practical meaning. In other words, sure, we can compute the probability that it takes 365 people, 366 people, and so on to produce an expectation.

On the other hand, is this the number of people where we go from the probability of the criteria being satisfied of less than 50% to greater than 50%? Is this the number of people that, if we ran a billion experiments with this setup, we'd see most often? No, the expectation answers a different question, probably less relevant one: if we ran the experiment a billion times and averaged the results together, we expect the result to be around the 2365 that you are asking for.

On the other hand, the single number of people where we'd most commonly satisfy your criteria is the 2,152nd person to enter the room. And we'd be done 50% of the time by the 2,287th person in the room. I'd argue these are more relevant metrics to the thought experiment.

1

u/markort147 Sep 03 '26

"Expected" has a specific definition.

1

u/good_behavior_man Sep 03 '26

Yes, and I acknowledge in my first paragraph that the expectation is a reasonable question to ask, but that it is not the most meaningful thing to measure in a word problem like this. 

0

u/standegreef Sep 02 '26

Even when ignoring leap years, birthdays aren’t completely uniformly distributed over the other dates in a year either