1

enter image description here

“”So I was thinking that $P(\text {no two matching socks next to each other}) = 1 - P(\text {at least one matching socks next to each other}).$

Letting $\text{“sock $i$ together”}$ mean the left sock $i$ and right sock $i$ being together,

the above is equivalent to $1 - P(\text{sock 1 together} \cup \text{sock 2 together} \cup \cdots\cup \text{sock $n$ together})$, where $\cup$ is the union.

Then I could use principle of inclusion-exclusion to expand $P(\text{sock 1 together U sock 2 together} \cup\cdots\cup \text{sock $n$ together}) = P(\text{sock 1 together}) + \cdots + P(\text{sock $n$ together}) - (P(\text{sock 1 together $n$ sock 2 together}) + \cdots) + P(\text{sock 1 together $n$ sock 2 together $n$ sock 3 together}) +\cdots \text{etc.}$

This seems like it's going to get very long (esp with n different pairs), and the multiple intersections make the probabilities harder to calculate as well—so I was wondering if people could help me figure out a perhaps more concise way.

space
  • 4,561
  • One more - https://math.stackexchange.com/questions/463035/no-husband-can-sit-next-to-his-wife-in-this-probability-question – Math Lover Jul 25 '21 at 19:18

1 Answers1

1

Another way to answer this question that wasn't illustrated in the posts mentioned by @MathLover is by using a "balls in bins" counting strategy.

Suppose we've enumerated pairs of socks with tags $1,2,\ldots,n$ and we call $E_j$ the event that the $j^{\text{th}}$ pair of socks is together. In order to apply the principle of inclusion$-$exclusion, we must develop an expression for $P(E_1\cap \ldots \cap E_j)$ which is the probability that pairs $1,\ldots ,j$ are all together.

Let's say you're holding onto pairs $1,\ldots ,j$ while the remaining $2n-2j$ socks are laid out in front of you in an arbitrary order. Note there are $2n-2j+1$ spaces in which you can insert these $j$ pairs of socks. Using a "balls in bins" counting strategy, we see there are $j! \cdot A_j$ ways to insert the $j$ pairs into the $2n-2j+1$ empty spaces, where $A_j$ is the number of non$-$negative integer solutions to $x_1 + \dots + x_{2n-2j+1}=j$. From stars and bars, $A_j={2n-j \choose 2n-2j}$, and since the socks within each pair may be rearranged in $2$ different ways, we have that $$P(E_1 \cap \ldots \cap E_j)=\frac{{2n-j \choose 2n-2j}\cdot j!\cdot 2^j \cdot (2n-2j)!}{(2n)!}$$ So from inclusion$-$ exclusion, $$\begin{eqnarray*}P(E_1 \cup \ldots \cup E_n)&=&\sum_{j=1}^n (-1)^{j-1}{n \choose j}P(E_1 \cap \ldots \cap E_j) \\ &=& \frac{n!}{(2n)!}\sum_{j=1}^n \frac{(-1)^{j-1}\cdot (2n-j)!\cdot 2^j}{j! \cdot (n-j)!}\end{eqnarray*}$$ Your answer is $1-P(E_1 \cup \ldots \cup E_n)$.

Matthew H.
  • 9,191
  • Thanks for the answer—it's making more sense to me now, but I have a question. Shouldn't we have a formula for P(Ek n ... n Em) instead of P(E1 n .. n Ej) since we could take the intersection of any E_i's together for PIE? Or does this not matter b/c ultimately the probabilities are the same if given the same number of events Ei? – space Jul 26 '21 at 01:35
  • The probabilities are the same regardless of which $j$ events you choose to intersect. That's where the ${n \choose j}$ term comes from in your sum. – Matthew H. Jul 26 '21 at 02:04
  • thank you! also what exactly do the x's represent (the x's that sum up to j)? – space Jul 26 '21 at 04:41
  • The variable $x_i$ counts the number of pairs between sock $i-1$ and sock $i$. For example, suppose $n=8$ and $j=5$ which means there are $16$ socks in total and pairs $1$ through $5$ are together. If we had $$x_1=2,x_2=1,x_3=0,x_4=0,x_5=1,x_6=0,x_7=1$$ We're saying that pairs $1$ and $2$ are all the way on the left end, pair $3$ is between sock $1$ and sock $2$, pair $4$ is between sock $4$ and sock $5$, while pair $5$ is all the way on the right end. The $j!$ counts the number of ways you can rearrange these pairs while preserving the number of pairs in between the socks. – Matthew H. Jul 26 '21 at 21:31