Jump to content
BrainDen.com - Brain Teasers
  • 0

Birthday Probability


BMAD
 Share

Question

At a movie theater, the manager announces that a free ticket will be given to the first person in line whose birthday is the same as someone in line who has already bought a ticket. You have the option of getting in line at any time. Assuming that you don't know anyone else's birthday, and that birthdays are uniformly distributed throughout a 365 day year, what position in line gives you the best chance of being the first duplicate birthday?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Let n be your position in the line, there are n-1 people ahead of you. Let A be the event that the people ahead of you all have different birthdays, and let B be the event that you have the same birthday as someone ahead of you. You will win iff both A and B happens. So P(win) = P(A and B) = P(A)*P(B|A). We know that P(A) = 365*364*...*(365-n+2)/365

n-1, and it's easily seen that P(B|A) = (n-1)/365. So P(win) = 365*364*...*(365-n+2)*(n-1)/365n. Consider the function f(n) as being your probability of winning in position n. We seek the value for n which maximizes f(n).

If we compare f(n+1) to f(n), most factors will fortunately cancel out.

f(n+1)/f(n) = 365*364*...*(365-n+2)*(365-n+1)*n/365n+1/(365*364*...*(365-n+2)*(n-1)/365n) = (365-n+1)*n/(365(n-1)) = (365n-n2+n)/(365n-365)

As long as this is greater than 1, the function f(n) keeps growing. Solving:

1 < (365n-n2+n)/(365n-365)

365n-365 < 365n-n2+n

-365 < -n2+n

365 > n2-n

Since n can only be positive integers, the inequality holds exactly for 0 < n < 20. So f(n+1) > f(n) as long as n < 20, and f(n+1) < f(n) as long as n > 19. Hence n = 20 yields the maximum value for f(n), as hinted by superprismatic's simulation. Entering f(20) into the calculator on my computer yields ~0.0323198575490432954774, which is not far from what the simulation yielded.

Link to comment
Share on other sites

  • 0

Let n be your position in the line, there are n-1 people ahead of you. Let A be the event that the people ahead of you all have different birthdays, and let B be the event that you have the same birthday as someone ahead of you. You will win iff both A and B happens. So P(win) = P(A and B) = P(A)*P(B|A). We know that P(A) = 365*364*...*(365-n+2)/365

n-1, and it's easily seen that P(B|A) = (n-1)/365. So P(win) = 365*364*...*(365-n+2)*(n-1)/365n. Consider the function f(n) as being your probability of winning in position n. We seek the value for n which maximizes f(n).

If we compare f(n+1) to f(n), most factors will fortunately cancel out.

f(n+1)/f(n) = 365*364*...*(365-n+2)*(365-n+1)*n/365n+1/(365*364*...*(365-n+2)*(n-1)/365n) = (365-n+1)*n/(365(n-1)) = (365n-n2+n)/(365n-365)

As long as this is greater than 1, the function f(n) keeps growing. Solving:

1 < (365n-n2+n)/(365n-365)

365n-365 < 365n-n2+n

-365 < -n2+n

365 > n2-n

Since n can only be positive integers, the inequality holds exactly for 0 < n < 20. So f(n+1) > f(n) as long as n < 20, and f(n+1) < f(n) as long as n > 19. Hence n = 20 yields the maximum value for f(n), as hinted by superprismatic's simulation. Entering f(20) into the calculator on my computer yields ~0.0323198575490432954774, which is not far from what the simulation yielded.

Nice analysis! I wish I had thought of that.

Link to comment
Share on other sites

  • 0

Let n be your position in the line, there are n-1 people ahead of you. Let A be the event that the people ahead of you all have different birthdays, and let B be the event that you have the same birthday as someone ahead of you. You will win iff both A and B happens. So P(win) = P(A and B) = P(A)*P(B|A). We know that P(A) = 365*364*...*(365-n+2)/365

n-1, and it's easily seen that P(B|A) = (n-1)/365. So P(win) = 365*364*...*(365-n+2)*(n-1)/365n. Consider the function f(n) as being your probability of winning in position n. We seek the value for n which maximizes f(n).

If we compare f(n+1) to f(n), most factors will fortunately cancel out.

f(n+1)/f(n) = 365*364*...*(365-n+2)*(365-n+1)*n/365n+1/(365*364*...*(365-n+2)*(n-1)/365n) = (365-n+1)*n/(365(n-1)) = (365n-n2+n)/(365n-365)

As long as this is greater than 1, the function f(n) keeps growing. Solving:

1 < (365n-n2+n)/(365n-365)

365n-365 < 365n-n2+n

-365 < -n2+n

365 > n2-n

Since n can only be positive integers, the inequality holds exactly for 0 < n < 20. So f(n+1) > f(n) as long as n < 20, and f(n+1) < f(n) as long as n > 19. Hence n = 20 yields the maximum value for f(n), as hinted by superprismatic's simulation. Entering f(20) into the calculator on my computer yields ~0.0323198575490432954774, which is not far from what the simulation yielded.

Nice analysis! I wish I had thought of that.

This is what I alluded to by the point of maximum slope on the cumulative probability curve.

The analysis sounds like that concept, so I wonder whether differentiating its expression as a second approach.

I'm not sure it's precisely what Rainman has done, which is the correct approach.

Link to comment
Share on other sites

  • 0

Let n be your position in the line, there are n-1 people ahead of you. Let A be the event that the people ahead of you all have different birthdays, and let B be the event that you have the same birthday as someone ahead of you. You will win iff both A and B happens. So P(win) = P(A and B) = P(A)*P(B|A). We know that P(A) = 365*364*...*(365-n+2)/365

n-1, and it's easily seen that P(B|A) = (n-1)/365. So P(win) = 365*364*...*(365-n+2)*(n-1)/365n. Consider the function f(n) as being your probability of winning in position n. We seek the value for n which maximizes f(n).

If we compare f(n+1) to f(n), most factors will fortunately cancel out.

f(n+1)/f(n) = 365*364*...*(365-n+2)*(365-n+1)*n/365n+1/(365*364*...*(365-n+2)*(n-1)/365n) = (365-n+1)*n/(365(n-1)) = (365n-n2+n)/(365n-365)

As long as this is greater than 1, the function f(n) keeps growing. Solving:

1 < (365n-n2+n)/(365n-365)

365n-365 < 365n-n2+n

-365 < -n2+n

365 > n2-n

Since n can only be positive integers, the inequality holds exactly for 0 < n < 20. So f(n+1) > f(n) as long as n < 20, and f(n+1) < f(n) as long as n > 19. Hence n = 20 yields the maximum value for f(n), as hinted by superprismatic's simulation. Entering f(20) into the calculator on my computer yields ~0.0323198575490432954774, which is not far from what the simulation yielded.

Nice analysis! I wish I had thought of that.

This is what I alluded to by the point of maximum slope on the cumulative probability curve.

The analysis sounds like that concept, so I wonder whether differentiating its expression as a second approach.

I'm not sure it's precisely what Rainman has done, which is the correct approach.

The method I used is very similar to differentiation. Differentiation also compares f(x) to some nearby value f(x+h), in order to tell whether the function is growing or declining. However, this particular function is only defined for integers, so it's not differentiable unless we first extend it in some way.

Link to comment
Share on other sites

  • 0

Right ... it's "discrete" differentiation.

And that permits a (nice) direct calculation as opposed to simulation.

I simulated the average first-duplicate position and got the kind-of well-known 23.

I am modifying the program now to show the median value.

The distribution is skewed, so the mean is slightly larger.

And, I guess, the median must be the point of greatest slope of the cumulative probability.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...