## 三、CRF概率计算问题

$$P\left( y|x \right) = \frac{1}{Z}e^{\sum_{}{}{\lambda f(x,yc)}}$$

$$Z = \sum_{Y}^{}e^{\sum_{}{}{\lambda f(x,yc)}}$$

$P(Y_i|X, Y_1,...,Y_{i-1},Y_(i+1),...,Y_n)=P({Y_i}|X,Y_{i-1},Y_{i+1})$ 则称P(Y|X)为线性链条件随机场

$$P\left( y|x \right) = \frac{1}{Z}exp(\sum_{}{}{\lambda f(x,y_{t - 1},y_{t})})$$

$$Z = \sum_{Y}{}{exp(\sum_{}{}{\lambda f(x,y_{t - 1},y_{t})})}$$

$$\alpha_0(x|y)= { \{_{0,y = start}^{1,y = others} }$$

$$\alpha_{i}{T}(x) = \alpha_{i - 1}{T}(x)M_{i}(x)$$

$\alpha_{i}(y|x)$的含义是从1到位置i，且位置i为y的序列的概率（没有归一化），由于y有m种取值，显然$\alpha_{i}{T}(x)$是一个m维向量

$$\beta_{n+1}(y|x)={\{_{1,y=stop}^{0,y=others}}$$

$$\beta_{i}(x) = M_{i + 1}(x)\beta_{i + 1}(x)$$

$\beta_{i}(y|x)$的含义是从位置i到n，且位置i为y的序列的概率（没有归一化），显然$\beta_{i}(x)$也是m维向量。

$$Z\left( x \right) = \alpha_{n}^{T}\left( x \right) 1 = 1^{T} \beta_{1}\left( x \right)$$

$$P\left( Y_{i} = y_{i} | x \right) = \frac{\alpha_{i}{T}(y_{i}|x)\beta_{i}(y_{i}|x)}{Z(x)}$$

$$P(Y_{i-1}=y_{i-1},Y_i = y_i |x)=\frac{{{\alpha_i}^T}(y_{i-1}|x){M_i}(y_{i-1},y_i|x){{\beta_i}(y_i|x)}}{Z(x)}$$

$$P\left( y | x \right) = P\left( Y_{1} = y_{1} | x \right)\prod_{i = 2}^{n}{P\left( Y_{i - 1} = y_{i - 1},Y_{i} = y_{i} | x \right)}$$

$E_{P(Y|X)}(f_k)=\sum_{y}P(y|x){f_k}(y,x)$

$={\sum_{i=1}^{n+1}}y_{i-1} \sum y_i f_k(y_{i-1},y_i,x,i)\bullet{\frac{{\alpha_i}^T(y_{i-1}|x)M_i (y_{i-1},{y_i}|x){\beta_i}(y_i|x)}{Z(x)}}$

$$E_{P(X,Y)}(f_{k}) = \sum_{x,y}{}{P(x,y)\sum_{i = 1}^{n + 1}{f_{k}(y_{i - 1},y_{i},x,i)}}$$

$$P\left( x,y \right) = \tilde{P}\left( x \right) P(y|x)$$

## Reference：

《统计学习方法》李航

https://zhuanlan.zhihu.com/p/26696451

Top