我正在尝试使用 Baum Welch 算法复制此表,用于隐马尔可夫模型。我无法将表达式放在中间,我正在尝试\ begin {align *} ... \ end {align *}
,但问题是垂直线被删除了。有人能帮我吗?
预期输出:
\usepackage{tabularx}
\usepackage{booktabs}
\begin{table}[H]
\centering
\label{tabla4}
\begin{tabularx}{\textwidth}{X}
\toprule
\textbf{Algorithm 5:} The Baum-Welch algorithm \\ \midrule
\textbf{Initialization:} \\
\ $\Theta_0, \lbrace O_{1:T} \rbrace$ \\
\\
\textbf{Looping:} \\
\textbf{for} $l = 1,..., l_{max}$ \textbf{do} \\
\ \ \vline \ \ 1. Forward-Backward calculations:\\
\ \ \vline \\
\ \ \vline \ \ $\alpha_1 (i) = \pi_i b_i (O_1), \ \beta_T (i) = 1$, \\
\ \ \vline \ \ $\alpha_t (i) = \left[ \sum_{j=1}^K \alpha_{t-1} (j) a_{ji} \right] b_j (O_t), \ \beta_t (i) = \sum_{j=1}^K a_{ij} b_j (O_{t+1}) \beta_{t+1} (j)$\\
\ \ \vline \ \ for $1 \leq i \leq K, \ 1 \leq t \leq T-1$\\
\ \ \vline \\
\ \ \vline \ \ 2. E-step: \\
\ \ \vline \\
\ \ \vline \ \ $\gamma_t (i) = \frac{\alpha_t (i) \beta_t (i)}{\sum_{j=1}^K \alpha_t (j) \beta_t (j)}, \ \xi_t (i,j) = \frac{\alpha_t (i) a_{ij} b_j (O_{t+1}) \beta_{t+1}(j) }{\sum_{i=1}^N \sum_{j=1}^N \alpha_t(i) a_{ij} b_j (O_{t+1} \beta_t (j))}$ \\
\ \ \vline \ \ for $1 \leq i \leq K, \ 1 \leq j \leq K, \ 1 \leq t \leq T-1$\\
\ \ \vline \ \ \\
\ \ \vline \ \ 3. M-step: \\
\ \ \vline \ \ \\
\ \ \vline \ \ $\pi_i = \frac{\gamma_1 (i)}{\sum_{j=1}^K \gamma_1(j)}, \ a_{ij} = \frac{\sum_{t=1}^T \varepsilon_t (i,j)}{ \sum_{k=1}^K \sum_{t=1}^T \varepsilon_t (i, k)}, \ w_{kd} = \frac{\sum_{t=1}^T \gamma_t (k, d)}{\sum_{t=1}^T \sum_{r=1}^D \gamma_t (k, r)}$\\
\ \ \vline \ \ for $1 \leq i \leq K,\ 1 \leq j \leq K, \ 1 \leq k \leq K, 1 \leq d \leq D$\\
\textbf{end} \\
\\
\textbf{Result:} $\lbrace \Theta_l \rbrace^{l_{max}}_{l=0} $ \\ \bottomrule
\end{tabularx}
\end{table}
答案1
您可能想要使用algorithm2e
:
\documentclass{article}
\usepackage[ruled,lined,shortend]{algorithm2e}
\usepackage{amsmath}
\renewcommand{\DataSty}[1]{\textbf{#1}}
\makeatletter
\renewcommand{\SetKwData}[2]{%
\algocf@newcommand{@#1}[1]{\DataSty{#2}: \ArgSty{##1}}%
\algocf@newcommand{#1}{%
\@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%
}%
\makeatother
\begin{document}
\begin{algorithm}
\SetKwData{Initialization}{Initialization}
\SetKwData{Looping}{Looping}
\SetKwData{Result}{Result}
\Initialization{$\Theta_0$, $\lbrace O_{1:T} \rbrace$}
\BlankLine
\Looping{}
\For{$l = 1,\dots, l_{\max}$}{
1. Forward-Backward calculations:
\begin{gather*}
\alpha_1 (i) = \pi_i b_i (O_1), \ \beta_T (i) = 1, \\
\alpha_t (i) = \Bigl[ \sum_{j=1}^K \alpha_{t-1} (j) a_{ji} \Bigr] b_j (O_t),
\ \beta_t (i) = \sum_{j=1}^K a_{ij} b_j (O_{t+1}) \beta_{t+1} (j)\\
\text{for }1 \leq i \leq K, \ 1 \leq t \leq T-1
\end{gather*}
2. E-step:
\begin{gather*}
\gamma_t (i) =
\frac{\alpha_t (i) \beta_t (i)}{\sum_{j=1}^K \alpha_t (j) \beta_t (j)},
\ \xi_t (i,j) =
\frac{\alpha_t (i) a_{ij} b_j (O_{t+1}) \beta_{t+1}(j)}
{\sum_{i=1}^N \sum_{j=1}^N \alpha_t(i) a_{ij} b_j (O_{t+1} \beta_t (j))} \\
\text{for }1 \leq i \leq K, \ 1 \leq j \leq K, \ 1 \leq t \leq T-1
\end{gather*}
3. M-step:
\begin{gather*}
\pi_i = \frac{\gamma_1 (i)}{\sum_{j=1}^K \gamma_1(j)},
\ a_{ij} =
\frac{\sum_{t=1}^T \varepsilon_t (i,j)}
{\sum_{k=1}^K \sum_{t=1}^T \varepsilon_t (i, k)},
\ w_{kd} =
\frac{\sum_{t=1}^T \gamma_t (k, d)}
{\sum_{t=1}^T \sum_{r=1}^D \gamma_t (k, r)} \\
\text{for }1 \leq i \leq K,\ 1 \leq j \leq K, \ 1 \leq k \leq K, 1 \leq d \leq D
\end{gather*}
}
\Result{$\lbrace \Theta_l \rbrace^{l_{\max}}_{l=0} $}
\caption{The Baum-Welch algorithm\label{baum-welch}}
\end{algorithm}
\end{document}