样例输入 1
3 3 A
0.3
0.5 0.2
0.9 0.8
add 1 1
add 3 0
del 1样例输出 1
2.350000
1.333333
0.432749对于每个操作,输出一行实数,表示操作结束后,在当前已知信息的条件下,小 R 在 $ n $ 局游戏中总共获胜的局数的期望是多少。
运用贝叶斯公式
第一问:
$$ \begin{aligned} p(x_2 = 1|x_1 = 1) &= 0.5 \ p(x_3 = 1|x_1 = 1) &= 0.5 \times 0.9 + 0.5 \times 0.8 = 0.85 \ E(x_1 +x_2 +x_3 |x_1 = 1) &= 0.5 + 0.85 + 1 = 2.35 \end{aligned} $$
第二问:
$$ \begin{aligned} p(x_2 = 1|x_1 = 1, x_3 = 0) &= \frac{p(x_3 =0|x_1=1,x_2=1)p(x_2 = 1|x_1 =1)}{p(x_3 =0|x_1 =1)} \approx 0.333 \ E(x_1 + x_2 + x_3|x_1 =1, x_3 = 0) &\approx 1.333 \end{aligned} $$
第三问:
对于
$$ p(x_2 = 1|x_3 = 0) = \frac{p(x_3 = 0|x_2 = 1)p(x_2 = 1)}{p(x_3 = 0)} $$
其中
$$ \begin{aligned} p(x_3 = 0|x_2 = 1) &= 0.1 \ p(x_2 = 1) &= 0.3 \times 0.5 + 0.7 \times 0.2 = 0.29 \ p(x_3 = 0) &= 0.29 \times 0.1 + 0.71 \times 0.2 = 0.171 \end{aligned} $$
所以
$$ p(x_2 = 1|x_3 = 0) = 0.1 \times 0.29/0.171 \approx 0.16959 $$
对于
$$ p(x_1 = 1|x_3 = 0) = \frac{p(x_3 =0|x_1=1)p(x_1=1)}{p(x_3 =0)} $$
其中
$$ \begin{aligned} p(x_3 = 0|x_1 = 1) &= 0.5 \times 0.1 + 0.5 \times 0.2 = 0.15 \ p(x_1 = 1) &= 0.3 \ p(x_3 = 0) &= 0.171 \end{aligned} $$
所以
$$ \begin{aligned} p(x_1 = 1|x_3 = 0) &= 0.15 \times 0.3/0.171 \approx 0.26316 \ E(x_1 + x_2 + x_3|x_3 = 0) &\approx 0.43275 \end{aligned} $$
3 3 A
0.3
0.5 0.2
0.9 0.8
add 1 1
add 3 0
del 12.350000
1.333333
0.432749