连续正面
Consecutive Heads
题目详情
掷一枚公平硬币。令 表示首次出现 个连续正面所需的抛掷次数。
计算 。
You have a fair coin. Denote as the number of flips required to see exactly consecutive heads.
Compute
解析
让我们从求解 开始:
是直到我们恰好看到 1 个正面为止的预期翻转次数。我们可以利用总概率定律将期望值的计算分成两部分的加权平均值:一个部分对应于第一次出现正面时的翻转次数,另一个对应于出现背面时的翻转次数。得出以下总和:
正如你从上面的总和中看到的,如果我们得到一个反面,我们本质上是“重新开始”,并且我们需要对单次反面翻转 (1) 和获得 1 个正面的预期翻转次数求和,即 。另一方面,如果我们得到正面,我们只需返回值 1,因为我们需要翻转 1 次才能看到正面。这就形成了一种递归关系,我们可以代入各个概率的值,求解我们发现它等于2。
现在我们来求解 : 通过与上述相同的逻辑,我们可以将期望计算为加权平均值,得出以下总和:
在第一个表达式中,我们具有相同的逻辑,如果我们得到尾部,我们会通过额外的滚动重新启动该过程。然而,在第二个求和中,我们有嵌套递归的情况,我们得到了正面。如果我们得到正面,我们可以得到反面并重新开始计算,但需要额外掷两次。或者,我们可以获得第二个连续的正面并完成该过程,值为 2。代入相应的概率并求解,得出 值为 6。
让我们从求解 开始: 求解此期望会产生嵌套表达式:
代入相应的概率并求解 ,结果为 14。
Original Explanation
Let's start by solving for :
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:
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, . 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 we find it equals 2.
Let's now solve for : By the same logic as above, we can compute the expectation as a weighted average, yielding the following sum:
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 value of 6.
Let's start by solving for : Solving for this expectation yields the nested expression:
Plugging in the respective probabilities and solving for yields 14.