Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

How Many People Stay in the Same Position?

There are 100 seats on a plane. If each of the 100 passengers randomly take a seat, how many people will have his/her own seat on average?

There is a classic way to solve this problem, which is to decompose a (complicated) random variable into a sum of simple random variables. This is an important trick. See this post for the use of this trick to calculate the covariance of observastions in two categories in a multinomial distribution.

Let’s generalize this problem to assume that there are nn seats and nn passengers. Let Yi=I(passenger i takes its seat)Y_i=I(\text{passenger } i \text{ takes its seat}), 1in1\le i \le n, where II is an indicator function. YiY_i’s are exchangeable, which means that for a fixed kk (1kn1\le k\le n), any subset of Yi:1in\\{Y_i: 1\le i \le n\\} with kk elements has the same distribution. Specially, it’s easy to see that

YiiidBernoulli(1n),Y_i\overset{iid}{\sim}\text{Bernoulli}(\frac{1}{n}),
YiYjiidBernoulli(1n(n1)),ij.Y_iY_j\overset{iid}{\sim}Bernoulli(\frac{1}{n(n-1)}), i\ne j.

So we have

EYi=1n,EY_i=\frac{1}{n},
EYiYj=1n(n1),ij,EY_iY_j=\frac{1}{n(n-1)}, i\ne j,
Var(Yi)=n1n2,Var(Y_i)=\frac{n-1}{n^2},
Cov(Y1,Y2)=EY1Y2EY1EY2=1n2(n1).Cov(Y_1,Y_2)=EY_1Y_2-EY_1EY_2=\frac{1}{n^2(n-1)}.

Let Xni=1nYiX_n\equiv\sum_{i=1}^nY_i, which is the number of passengers taking their own seats. From above results we know that

E(Xn)=E(i=1nYi)=i=1nEYi=nEY1=n1n=1,E(X_n)=E\left( \sum_{i=1}^nY_i\right)=\sum_{i=1}^n E Y_i=n E Y_1=n\frac{1}{n}=1,
Var(Xn)=Var(i=1nYi)=i=1nVar(Yi)+ijCov(Yi,Yj)=nVar(Y1)+n(n1)Cov(Y1,Y2)=nn1n2+n(n1)1n2(n1)=1.\begin{align} Var\left( X_n\right) &= Var\left( \sum_{i=1}^nY_i\right) =\sum_{i=1}^n Var(Y_i)+\sum_{i\ne j}Cov(Y_i,Y_j) \nonumber \newline &= nVar(Y_1)+n(n-1)Cov(Y_1,Y_2) \nonumber \newline &= n\frac{n-1}{n^2}+n(n-1)\frac{1}{n^2(n-1)}=1. \nonumber \end{align}

Surprisingly, both the mean and the variance of XnX_n is 1, which suggests that we can predict XnX_n, i.e. the number of integers that have the same position as their original position very well.

The above solution is elegant. However, I’d like to try to solve this problem using my preferred universal procedure. Let YiY_i and XiX_i, 1in1\le i \le n, be as defined above. Conditioning XnX_n on Y1Y_1 gives us a recursive/differtial equation. If Y1=1Y_1=1 (with probability 1n\frac{1}{n}), i.e., the first passenger sits on its seat, then Xn=1+Xn1X_n = 1 + X_{n-1}; It’s a little tricky when Y1=0Y_1=0 (with probability 11n1-\frac{1}{n}), i.e., the first passenger sits on other people’s seat. Assume the first passenger takes kthk^{th} (2kn2\le k\le n) passenger’s seat. If we pretend that seat 1 is the kthk^{th} passenger’s seat, then we have Xn=Xn1X_n = X_{n-1}. However, seat 1 is not kthk^{th} passenger’s seat, and we cannot count it into Xn1X_{n-1}. Let EkI(passenger k sits on seat 1)E_k\equiv I(\text{passenger } k \text{ sits on seat 1}). We only miss count Xn1X_{n-1} by extra 1 when Ek=1E_k=1, so when Y1=0Y_1=0 we have

Xn=Xn1Ek.X_n = X_{n-1} - E_k.

It’s easy to see that EkBernoulli(1n1)E_k\sim\text{Bernoulli}(\frac{1}{n-1}). So using the conditional expectation formula, we have

EXn=E(E(XnY1))=E(1n(1+Xn1)+(11n)(Xn1Ek))=EXn1,\begin{align} EX_n &= E(E(X_n|Y_1))\nonumber\newline &= E\left(\frac{1}{n}(1 + X_{n-1}) + (1-\frac{1}{n}) (X_{n-1} - E_k)\right)\nonumber\newline &=EX_{n-1}, \end{align}

where EX1=1EX_1=1. This is the simplest recursive/differential equation. Anyone can immediately see that EXn=1,n1EX_n=1, \forall n\ge1 is the solution to this recursive/differential equation.