mindstalk: (Default)
Yeah, I'm behind on posting news links and such. Moving on!

Given 11 people, what is the probability that 3 of the 11 share the same birthday? Assuming uniform distribution of birthdays in the population, of course.

This seems a lot harder than the classic problem of finding whether at least two have the same birthday. I debunked a couple of answers, came up with a nice one of my own for "at least 3 share, and I don't care about anyone else" which came nowhere near simulation, then someone else came up with an answer for "3 people share a birthday, and the other 8 don't share any birthdays" which matched debugged simulation, and that one's actually fairly easy in retrospect (in my defense, it wasn't the problem I'd been thinking about.) I still don't know why I'm so far off for the "at least" case.

Date: 2010-02-18 08:03 (UTC)From: [identity profile] thomasyan.livejournal.com
Gah, I read this just before going to bed. Damn you!

Date: 2010-02-18 08:08 (UTC)From: [identity profile] dogofjustice.livejournal.com
First approximation: What is the chance that at least three people share a birthday of January 1st? Let's ignore leap years.

1 - P(nobody has that birthday) - P(one person has it) - P(two have it)
= 1 - (364/365)^11 - 11 * (364/365)^10 * (1/365) - 55 * (364/365)^9 * (1/365)^2
= about 3.3378e-6

So, double-counting the cases where two birthdays are triple-shared and triple-counting the three birthday case, we get a 0.12183% chance.

For a precise answer, we'd use inclusion-exclusion. Subtract 365*364/2 times the chance a particular pair of birthdays is triple-shared, and add 365*364*363/6 times the chance a particular triplet is triple-shared. This is a bit tedious since you need to subtract six different terms from 1 to calculate the former chance, and ten different terms to get the latter.

Date: 2010-02-18 08:20 (UTC)From: [identity profile] dogofjustice.livejournal.com
Oh, this deals with the "at least 3" case. "Exactly 3" is actually a bit cleaner, though:

A = P(exactly three people share a given birthday) = 11*10*9/6 * (364/365)^8 * (1/365)^3
B = P(exactly three people share a given birthday, and exactly three people share another given birthday) = 11!/(5!3!3!) * (363/365)^5 * (1/365)^6
C = P(three different given birthdays exactly triple-shared) = 11!/(2!3!3!3!) * (362/365)^2 * (1/365)^9

Exact answer = 365 * A - 365*364/2 * B + 365*364*363/6 * C

Date: 2010-02-18 17:51 (UTC)From: [identity profile] mindstalk.livejournal.com
Even cleaner is "exactly 3 people share a birthday, and no one else shares any"

Choose(11,3)*(1/365)^2*Prod(364,356,-1)/365^8
Edited Date: 2010-02-18 17:51 (UTC)

Date: 2010-02-18 09:32 (UTC)From: [identity profile] mindstalk.livejournal.com
Where you multiplied 3.3378e-6 by 365? That gives a pretty good approximation. I did 1-p(no match)-p(pair)-p(2 pair)-p(3 pairs)-p(4 pairs) and get 0.121805%. Simulation is around .122%, though it's hard to get many significant digits with such improbable events.

Though a couple of incorrect logics give approximately correct answers. Like "there are 165 triplets, and the chance of a random triplet having the same birthday is 1/365^2, so 165/365^2" Or the slightly better "1-(1-1/365^2)^165"

Date: 2010-02-18 17:34 (UTC)From: [identity profile] oniugnip.livejournal.com
ext_110843: (Default)
I like that you did this in simulation!

(would you post the code?)

Date: 2010-02-18 17:46 (UTC)From: [identity profile] mindstalk.livejournal.com
Well, I did math first, until someone on gale did simulation and got wildly different numbers, so I did sim and got the same wildly different number.

It's nothing much:
from random import *
triplets=0
for j in xrange(100000):
    bdays={}
    for i in range(11):
        b=randint(1,365)
        if b in bdays:
            bdays[b]+=1
        else:
            bdays[b]=1
#    if max(bdays.values()) == 2 and len(bdays)==8:
    if max(bdays.values()) >= 3 
       triplets+=1

print triplets


Commented line is for finding the probability of exactly 3 pairs, vs. at least one triplet-or-more.

First version was less elegant and ultimately less flexible:

from random import *
triplets=0
for j in xrange(100000):
    bdays=[]
    for i in range(11):
        bdays.append(randint(1,365))
    if len(bdays)==len(set(bdays)):
        continue
    else:
        for i in range(11):
            match=0
            for k in range(i+1,11):
                if bdays[i]==bdays[k]:
                    match+=1
            if match>=2:
                triplets+=1

print triplets


which actually inflates 'match' but for these purposes it doesn't matter because we only care about the threshold.

Python code, if that's not obvious.
Edited Date: 2010-02-18 17:48 (UTC)

Profile

mindstalk: (Default)
mindstalk

June 2025

S M T W T F S
123 45 67
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Expand Cut Tags

No cut tags

Style Credit

Page generated 2025-06-09 10:23
Powered by Dreamwidth Studios
OSZAR »