返回题库

连续正面

Consecutive Heads

专题
Probability / 概率
难度
L5

题目详情

掷一枚公平硬币。令 XiX_i 表示首次出现 ii 个连续正面所需的抛掷次数。

计算 E(X1),E(X2),E(X3)\mathbb{E}(X_1), \mathbb{E}(X_2), \mathbb{E}(X_3)

You have a fair coin. Denote XiX_i as the number of flips required to see exactly ii consecutive heads.

Compute E(X1),E(X2),E(X3)\mathbb{E}(X_1), \mathbb{E}(X_2), \mathbb{E}(X_3)

解析

让我们从求解 E(X1)\mathbb{E}(X_1) 开始:

E(X1)\mathbb{E}(X_1) 是直到我们恰好看到 1 个正面为止的预期翻转次数。我们可以利用总概率定律将期望值的计算分成两部分的加权平均值:一个部分对应于第一次出现正面时的翻转次数,另一个对应于出现背面时的翻转次数。得出以下总和:

\newline E(X1)=P(Tail)[1+E(X1)]+P(Head)1\mathbb{E}(X_1) = \mathbb{P}(Tail)*[1+\mathbb{E}(X_1)] + \mathbb{P}(Head)*1 \newline

正如你从上面的总和中看到的,如果我们得到一个反面,我们本质上是“重新开始”,并且我们需要对单次反面翻转 (1) 和获得 1 个正面的预期翻转次数求和,即 E(X1)\mathbb{E}(X_1)。另一方面,如果我们得到正面,我们只需返回值 1,因为我们需要翻转 1 次才能看到正面。这就形成了一种递归关系,我们可以代入各个概率的值,求解E(X1)\mathbb{E}(X_1)我们发现它等于2。

\newline 现在我们来求解 E(X2)\mathbb{E}(X_2): 通过与上述相同的逻辑,我们可以将期望计算为加权平均值,得出以下总和:

\newline E(X2)=P(Tail)(1+E(X2))+P(Head)[P(Tail)(2+E(X2))+P(Head)2]\mathbb{E}(X_2) = \mathbb{P}(Tail)*(1+\mathbb{E}(X_2)) + \mathbb{P}(Head)*[\mathbb{P}(Tail)*(2+\mathbb{E}(X_2)) + \mathbb{P}(Head)*2] \newline

在第一个表达式中,我们具有相同的逻辑,如果我们得到尾部,我们会通过额外的滚动重新启动该过程。然而,在第二个求和中,我们有嵌套递归的情况,我们得到了正面。如果我们得到正面,我们可以得到反面并重新开始计算,但需要额外掷两次。或者,我们可以获得第二个连续的正面并完成该过程,值为 2。代入相应的概率并求解,得出 E(X2)\mathbb{E}(X_2) 值为 6。

\newline 让我们从求解 E(X3)\mathbb{E}(X_3) 开始: 求解此期望会产生嵌套表达式:

\newline E(X3)=P(Tail)(1+E(X3))+P(Head)[P(Tail)(2+E(X3))+P(Head)[P(Tail)(3+E(X3)+P(Head)3]]\mathbb{E}(X_3) = \mathbb{P}(Tail)*(1+\mathbb{E}(X_3)) + \mathbb{P}(Head)*[\mathbb{P}(Tail)*(2+\mathbb{E}(X_3)) + \mathbb{P}(Head)*[\mathbb{P}(Tail)*(3+\mathbb{E}(X_3) + \mathbb{P}(Head)*3]] \newline

代入相应的概率并求解 E(X3)\mathbb{E}(X_3),结果为 14。


Original Explanation

Let's start by solving for E(X1)\mathbb{E}(X_1):

E(X1)\mathbb{E}(X_1) is the expected number of flips until we see exactly 1 head. We can use the Law of Total Probability to split the calculation of expectation into a weighted average of two parts: one which corresponds to the number of flips if we first get a head, and the other the number of flips which correspond to a tail. This yields the following sum:

\newline E(X1)=P(Tail)[1+E(X1)]+P(Head)1\mathbb{E}(X_1) = \mathbb{P}(Tail)*[1+\mathbb{E}(X_1)] + \mathbb{P}(Head)*1 \newline

As you can see from the sum above, if we get a tails we essentially 'restart' and, we're left summing the single tails flip (1) and the expected number of flips to get 1 head, E(X1)\mathbb{E}(X_1). On the other hand, if we get a heads, we would simply return the value 1 because it took 1 flips for us to witness the head. This forms a kind of recursive relationship, we can substitute in the values for respective probabilities, and solving for E(X1)\mathbb{E}(X_1) we find it equals 2.

\newline Let's now solve for E(X2)\mathbb{E}(X_2): By the same logic as above, we can compute the expectation as a weighted average, yielding the following sum:

\newline E(X2)=P(Tail)(1+E(X2))+P(Head)[P(Tail)(2+E(X2))+P(Head)2]\mathbb{E}(X_2) = \mathbb{P}(Tail)*(1+\mathbb{E}(X_2)) + \mathbb{P}(Head)*[\mathbb{P}(Tail)*(2+\mathbb{E}(X_2)) + \mathbb{P}(Head)*2] \newline

In the first expression, we have the same logic where we restart the process with one additional roll if we get a tails. In the second sum, however, we have the nested recursive case where we get a heads. If we get a heads, we can either get a tails and restart with calculation, but with 2 additional rolls. Or, we can get a second consecutive heads and complete the process, with a value of 2. Plugging in the respective probabilities and solving yields an E(X2)\mathbb{E}(X_2) value of 6.

\newline Let's start by solving for E(X3)\mathbb{E}(X_3): Solving for this expectation yields the nested expression:

\newline E(X3)=P(Tail)(1+E(X3))+P(Head)[P(Tail)(2+E(X3))+P(Head)[P(Tail)(3+E(X3)+P(Head)3]]\mathbb{E}(X_3) = \mathbb{P}(Tail)*(1+\mathbb{E}(X_3)) + \mathbb{P}(Head)*[\mathbb{P}(Tail)*(2+\mathbb{E}(X_3)) + \mathbb{P}(Head)*[\mathbb{P}(Tail)*(3+\mathbb{E}(X_3) + \mathbb{P}(Head)*3]] \newline

Plugging in the respective probabilities and solving for E(X3)\mathbb{E}(X_3) yields 14.