18. (10-11 grades, 5 points) Favorite Pair. On the drying rack, in a random order (as taken out of the washing machine), there are p socks. Among them are two favorite socks of the Absent-Minded Scientist. The socks are hidden by a drying sheet, so the Scientist cannot see them and takes one sock at a time by feel. Find the expected number of socks removed by the Scientist by the time he has both of his favorite socks.

![](https://cdn.mathpix.com/cropped/2024_05_06_ad4793eab3ce977a151bg-22.jpg?height=320&width=509&top_left_y=2344&top_left_x=1416)
Solution. It is convenient to form a triangular table. The shaded cells correspond to pairs of favorite socks. For example, the pair $(2; 4)$, marked with an "X", corresponds to the case where the first favorite sock was the second one, and the second one was the fourth in the sequence. All pairs are equally likely, and their total number is $C_{n}^{2}$.

The table shows the distribution of the random variable $\xi$ "Number of socks removed". Essentially, the table represents an inverted diagram of this distribution: the values of $\xi$ are taken from the first row, and the corresponding probabilities are depicted below them as shaded bars.

$$
\xi \sim\left(\begin{array}{cccccc}
2 & 3 & \cdots & k & \cdots & n \\
\frac{1}{C_{n}^{2}} & \frac{2}{C_{n}^{2}} & \cdots & \frac{k-1}{C_{n}^{2}} & & \frac{n-1}{C_{n}^{2}}
\end{array}\right)
$$

Let's find the expected value:

$$
\begin{gathered}
\mathrm{E} \xi=\frac{1}{C_{n}^{2}} \sum_{k=2}^{n} k(k-1)=\frac{1}{C_{n}^{2}}\left(\sum_{k=2}^{n} k^{2}-\sum_{k=2}^{n} k\right)= \\
=\frac{1}{C_{n}^{2}}\left(\sum_{k=1}^{n} k^{2}-\sum_{k=1}^{n} k\right)=\frac{1}{C_{n}^{2}}\left(\frac{n(n+1)(2 n+1)}{6}-\frac{(n+1) n}{2}\right)= \\
=\frac{1}{C_{n}^{2}} \frac{n(n+1)(2 n-2)}{6}=\frac{1}{C_{n}^{2}} \frac{n(n+1)(n-1)}{3}=\frac{2(n+1)}{3} .
\end{gathered}
$$

A geometric solution is possible: the expected value is the x-coordinate of the center of mass $M$ of the diagram. Let's draw an auxiliary triangle with the same center of mass and find the x-coordinate. It is equal to the arithmetic mean of the x-coordinates of the vertices:

$$
\frac{n+n+2}{3}=\frac{2(n+1)}{3} \text {. }
$$

|  | 2 | 3 | 4 | 5 | $\ldots$ | $n$ |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 1 |  |  |  |  |  |  |
| 2 |  |  |  |  |  |  |
| 3 |  |  |  |  |  |  |
| 4 |  |  |  |  |  |  |
| 5 |  |  |  |  |  |  |
| $n-1$ |  |  |  |  |  | $\vdots$ |
|  | 2 |  |  |  | $\frac{2(n+1)}{3}$ | $n$ |
|  |  |  |  |  |  |  |