Secret Santa

Six friends are doing a "secret santa gift exchange". Their names are placed into a hat, and each person chooses a name randomly (without replacement) from the hat.

However, this leads to the possibility that someone chooses their own name and doesn’t get a gift! What is the expected value for the number of people who will choose their own name?


The answer is 1.00.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Abhishek Sinha
Sep 7, 2015

In general, assume that there are n n people numbered 1 , 2 , , n 1,2,\ldots, n . Let I k I_k denote the indicator variable for the event that the k k th friend chooses his own name. Clearly, P ( I k = 1 ) = 1 n , k \mathbb{P}(I_k=1)=\frac{1}{n}, \hspace{5pt} \forall k Let the random variable N N denote the total number people choosing his own name. Clearly, N = k = 1 n I k N=\sum_{k=1}^{n}I_k Taking expectation of both sides and using linearity of expectations , we have E N = k = 1 n P ( I k = 1 ) = 1 \mathbb{E}N=\sum_{k=1}^{n}\mathbb{P}(I_k=1)=1

Brock Brown
Sep 4, 2015

Python 3.4:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import random
from time import time
friends = list(range(6))
def no_gifts():
    hat = friends[:]
    count = 0
    for friend in friends:
        gift = random.choice(hat)
        if gift == friend:
            count += 1
        hat.remove(gift)
    return count
trials = 0
count = 0
end = time() + 10
while time() < end:
    count += no_gifts()
    trials += 1
print ("Answer:", count/trials)

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...