# 概率计算问题 - 前向算法

## 定义

**前向概率**：给定马尔可夫模型$$\lambda$$，定义“到时刻t为止，部分观测序列为o1,o2,...,ot，且t时刻的状态为qi”的概率为前向概率，记作：

$$
\alpha\_t(i) = P(o\_1,o\_2,\cdots,o\_t,i\_t=q\_i|\lambda)
$$

## 原理

这是**状态DP**的思想。\
局部计算前向概率，利用路径结构将前向概率递推到全局（这一句没看懂）。\
每一次计算直接利用前一个时刻的计算结果，避免重复计算。

## 过程

**输入**：\
隐马尔可夫模型$$\lambda$$\
观测序列O\
**输出**：\
观测序列概率$$P(O|\lambda)$$ **过程**： 1. 初值：

$$
\alpha\_1(i) = \pi\_ib\_i(o\_1)
$$

1. 递推： &#x20;

   $$
   \alpha\_{t+1}(i) = \[\sum\_{j=1}^N\alpha\_t(j)a\_{ji}]b\_i(o\_{t+1})
   $$
2. 终止： &#x20;

   $$
   P(O|\lambda) = \sum\_{i=1}^N\alpha\_T(i)
   $$

**注意**$$\alpha$$**和**$$a$$**的不同**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windmising.gitbook.io/lihang-tongjixuexifangfa/hmm/3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
