# 一类概率期望问题的杀器：势函数和鞅的停时定理

1. $\mathbb{E}[\, \phi(A_{t+1})-\phi(A_t) \mid A_t, A_{t-1}, \dots, A_1, A_0 \,] = -1.$
2. $\phi(A_T)$为常数。

$$\mathbb{E}[\, X_{t+1}-X_t \mid X_t, X_{t-1}, \dots, X_1, X_0 \,] = 0,$$

$$\mathbb{E}[X_T] = \mathbb{E}[X_0],$$

$$\mathbb{E}[T] = \phi(A_0)-\phi(A_T).$$

## 例题1

CodeForces 1349D. Slime and Biscuits

$$m = \sum_{i=1}^n a_i.$$

$$\phi(A_t) = \sum_{i=1}^n f(a_{t,i}).$$

$$\mathbb{E}[\,\phi(A_{t+1})\mid A_t, \dots, A_0 \,] = \mathbb{E}[\,\phi(A_{t+1})\mid A_t \,].$$

\begin{aligned} \mathbb{E}[\,\phi(A_{t+1})\mid A_t \,] & = \sum_{i} \sum_{j\neq i} \frac {a_{t,i}} {m(n-1)} \left[ f(a_{t,i}-1)+f(a_{t,j}+1)+\sum_{k \notin \{i,j\}} f(a_{t,k}) \right] \\ & = \sum_i \left[ \frac {a_{t,i}} m f(a_{t,i}-1) + \frac {m-a_{t,i}} {m(n-1)} f(a_{t,i}+1) + \frac {(m-a_{t,i})(n-2)} {m(n-1)} f(a_{t,i}) \right]. \end{aligned}

$$\sum_i f(a_{t,i}) = \sum_i \left[ \frac {a_{t,i}} m f(a_{t,i}-1) + \frac {m-a_{t,i}} {m(n-1)} f(a_{t,i}+1) + \frac {(m-a_{t,i})(n-2)} {m(n-1)} f(a_{t,i}) + \frac {a_{t,i}} m \right].$$

$$f(a) = \frac a m f(a-1) + \frac {m-a} {m(n-1)} f(a+1) + \frac{(m-a)(n-2)}{m(n-1)} f(a) + \frac a m.$$

$$f(a+1) = \left[ \frac {m(n-1)} {m-a} - (n-2) \right] f(a) - \frac {a(n-1)} {m-a} \left( f(a-1)+1 \right).$$

$$\mathbb{E}[T] = \sum_{i} f(a_{0,i}) - \left(f(m)+(n-1)f(0)\right).$$

## 例题2

CodeForces 850F. Rainbow Balls

$$m = \sum_{i=1}^n a_i.$$

$$\phi(A_t) = \sum_{i=1}^n f(a_{t,i}).$$

1. 以$\frac {a_{t,i}} {m} \cdot \frac {a_{t,j}} {m-1}$的概率，将球$j(j \neq i)$染成球$i$的颜色；
2. 以$\sum_i \frac {a_{t,i}(a_{t,i}-1)} {m(m-1)}$的概率，不发生任何变化。

\begin{aligned} \mathbb{E}\left[\,\phi(A_{t+1})\mid A_t\,\right] & = \sum_{i} \sum_{j \neq i} \frac {a_{t,i}a_{t,j}} {m(m-1)} \left[ f(a_{t,i}+1) + f(a_{t,j}-1) + \sum_{k \notin \{i,j\}} f(a_{t,k}) \right] + \sum_i \frac {a_{t,i}(a_{t,i}-1)} {m(m-1)} \sum_k f(a_{t,k}) \\ & = \sum_i \left[ \frac {a_{t,i}(m-a_{t,i})} {m(m-1)} \left( f(a_{t,i}+1) + f(a_{t,i}-1) \right) + \left(1-\frac {2a_{t,i}(m-a_{t,i})} {m(m-1)} \right) f(a_{i,t}) \right]. \end{aligned}

$$\sum_{i} f(a_{t,i}) = \sum_i \left[ \frac {a_{t,i}(m-a_{t,i})} {m(m-1)} \left( f(a_{t,i}+1) + f(a_{t,i}-1) \right) + \left(1-\frac {2a_{t,i}(m-a_{t,i})} {m(m-1)} \right) f(a_{i,t}) + \frac {a_{t,i}} {m} \right],$$

$$\sum_i \left[ \frac {a_{t,i}(m-a_{t,i})} {m(m-1)} \left( f(a_{t,i}+1) + f(a_{t,i}-1) - 2f(a_{t,i}) \right) + \frac {a_{t,i}} {m} \right] = 0.$$

$$\frac {a(m-a)} {m(m-1)} \left( f(a+1) + f(a-1) - 2f(a) \right) + \frac {a} {m} = 0,$$

$$f(a+1)+f(a-1)-2f(a) = -\frac{m-1}{m-a}.$$

$$g(a+1) - g(a) = -\frac{m-1}{m-a}.$$

$$g(x) = g(0)-\sum_{a=0}^{x-1} \frac{m-1}{m-a}.$$

$$f(x) = f(0)+\sum_{a=1}^x g(a) = f(0) + \sum_{a=1}^x \left[ g(0)-\sum_{b=0}^{a-1} \frac{m-1}{m-b} \right] = f(0)+xg(0)-(m-1)x+(m-1)(m-x)\sum_{b=0}^{x-1} \frac {1} {m-b}.$$

$$f(x) = (m-1)(m-x)\sum_{b=0}^{x-1}\frac {1} {m-b}.$$

$$\mathbb{E}[T] = \phi(A_0)-\phi(A_T) = \sum_{i} f(a_{0, i}).$$

## 例题3

CodeForces 1025G. Company Acquisitions

$$\sum_{i=1}^{m_t} a_{t, i} = n.$$

$$\phi(A_t) = \sum_{i=1}^{m_t} f(a_{t, i}).$$

\begin{aligned} \mathbb{E}\left[\,\phi(A_{t+1})\mid A_t\,\right] & = \sum_{i} \sum_{j \neq i} \frac 1 {m_t(m_t-1)} \left[ (a_{t,i}-1) f(1) + f(a_{t, j}+1) + \sum_{k \notin \{i,j\}} f(a_{t,k}) \right] \\ & = \sum_i \left[ \frac 1 {m_t} f(a_{t,i}+1) + \left(1 - \frac 2 {m_t}\right) f(a_{t,i}) \right] + \frac{n-m_t}{m_t} f(1). \end{aligned}

$$\sum_i f(a_{t,i}) = \sum_i \left[ \frac 1 {m_t} f(a_{t,i}+1) + \left(1 - \frac 2 {m_t}\right) f(a_{t,i}) + \frac{n-m_t}{m_t^2} f(1) + \frac 1 {m_t} \right].$$

$$f(a) = \frac 1 m f(a+1) + \left(1 - \frac 2 m \right) f(a) + \frac {n-m} {m^2} f(1) + \frac 1 m$$

$$f(a+1)-2f(a) + \frac{n-m}{m} f(1) + 1 = 0.$$

$$f(a) = 1-2^{a-1}.$$

$$\mathbb{E}[T] = \phi(A_0) - \phi(A_T) = \sum_{i} \left( 1-2^{a_{0, i}-1} \right) - \left( 1-2^{n-1} \right).$$

posted @ 2020-05-14 17:52  liouzhou_101  阅读(416)  评论(5编辑  收藏