12. Gnomes and the Thunderstorm. In a terrible thunderstorm, n gnomes are climbing up a rope ladder in a chain. If there is a thunderclap, each gnome, independently of the others, may fall with probability $p(0<p<1)$. If a gnome falls, they knock down all the gnomes below them. Find:

a) The probability that exactly $k$ gnomes will fall.

b) The expected number of gnomes that will fall.
Solution. Let $q=1-p$ be the probability that a gnome will not fall from fright (although, it might get scared and even fall, but not from fright, but because someone fell on top of it).

a) Exactly $k$ gnomes will fall only if the $k$-th gnome, counting from the bottom, falls from fright and none of the $n-k$ gnomes above fall. Thus, the desired probability is $q^{n-k} \cdot p = p \cdot (1-p)^{n-k}$.

b) We use indicators ${ }^{2}$. Let the random variable $I_{j}$ be 1 if the $j$-th gnome falls and 0 if it does not fall. The probability that the $j$-th gnome will not fall is the probability that it will not fall itself and that none of the $j-1$ gnomes above it will fall:

$$
\mathrm{P}\left(I_{j}=0\right)=q^{j} . \text { Then } \mathrm{E} I_{j}=\mathrm{P}\left(I_{j}=1\right)=1-q^{j}
$$

The total number of fallen gnomes is the sum of all indicators, so the expectation of this value is

$$
\begin{gathered}
\mathrm{E} I_{1}+\mathrm{E} I_{2}+\ldots+\mathrm{E} I_{n}=n-q-q^{2}-q^{3}-\ldots-q^{n}= \\
=n-q \cdot \frac{1-q^{n}}{1-q}=n-\frac{q}{p}+\frac{q^{n+1}}{p}=n+1-\frac{1}{p}+\frac{(1-p)^{n+1}}{p}
\end{gathered}
$$

Answer: a) $p(1-p)^{n-k}$; b) $n+1-\frac{1}{p}+\frac{(1-p)^{n+1}}{p}$.