连续双正面计数
Number of Double Heads
题目详情
抛硬币 10 次,把结果写成字符串。定义 “HH” 的出现次数允许重叠(例如 HHH 中 HH 的次数为 2)。
问:HH 的出现次数期望是多少?
A coin is tossed 10 times and the output written as a string. What is the expected number of HH? Note that in HHH, number of HH = 2. (eg: expected number of HH in 2 tosses is 0.25, 3 tosses is 0.5)
Hint
Recursion
解析
令 为抛 次的 HH 期望次数。对每个相邻位置 ,它为 HH 的概率是 。
一共有 对相邻位置,因此
取 得 。
Original Explanation
Solution
Let the expected number of HH for n tossed is E(n). So, probability that an (n-1) toss experiments, ends in T is 1/2. So, E(n) = 1/2 * E(n-1) + 1/2 * ( 1/2 * (E(n-1)+1) + 1/2 * (E(n-1))) (The first case when it ends in T. & The second case when it ends in H. In the second case, if you get an H then, you get 1 more HH. ) So, E(n) = E(n-1) + 1/4, us E(2) = 1/4 So, E(n) = (n-1)/4 For n=10, E(10) = 2.25