以下所有方程式在 CodeCogs 中均可用,但在 Texmaker 中仍然出现错误。\begin{equation}
是第 501 行
\begin{align}
P(c)= \frac{1}{n} \sum_{i=1}^{n} P(c\vert\vec{x_i})
\mu_{c,j} = \sum_{i=1}^{n} (\frac{P(c\vert\vec{x_i})}{nP(c)})x_{i,j}
(\sum_{c})_{j,k} = \sum_{i=1}^{n}(\frac{P(c\vert\vec{x_i})}{nP(c)})(x_{i,j} - \mu_{c,j})(x_{i,k} - \mu_{c,k})
P(c\vert\vec{x_i}) = \frac{P(\vec{x_i}\vertc)P(c))}{\sum_{i=1}^{k}P(\vec{x_i}\vertc)P(c)}
P(\vec{x_i}|c) = \frac{1}{\sqrt{2\pi(\sum_{c})}} exp(- \frac{1}{2}(\vec{x_i} - \vec{\mu_c})^T \sum_{c}^{-1}(\vec{x_i} - \vec{\mu_c}))
\end{align}
错误:
! Missing $ inserted.
<inserted text>
$
l.501
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Display math should end with $$.
<to be read again>
\par
l.501
答案1
除了缺少\\
用于终止行的 s 之外,我强烈建议您阅读amsmath
包文档。
我无论如何都找不到该vertc
符号,我将其翻译成了\vert c
。
数学里不要留空行;
我还手动调整了括号的高度,并exp
用适当的运算符替换\exp
。
我还用(\sum_c)_{j,k}
来代替\sum_c{\mathstrut}_{j,k}
,以去掉括号
我希望已经捕捉到了一切
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
P(c)= \frac{1}{n} \sum_{i=1}^{n} P(c\vert\vec{x_i})\\
\mu_{c,j} = \sum_{i=1}^{n} \Bigl(\frac{P(c\vert\vec{x_i})}{nP(c)}\Bigr)x_{i,j}\\
\sum_{c}{\mathstrut}_{j,k} = \sum_{i=1}^{n}\Bigl(\frac{P(c\vert\vec{x_i})}{nP(c)}\Bigr)(x_{i,j} - \mu_{c,j})(x_{i,k} - \mu_{c,k})\\
P(c\vert\vec{x_i}) = \frac{P(\vec{x_i}\vert c)P(c))}{\sum_{i=1}^{k}P(\vec{x_i}\vert c)P(c)}\\
P(\vec{x_i}|c) = \frac{1}{\sqrt{2\pi\sum_{c}}} \exp\Bigl(- \frac{1}{2}(\vec{x_i} - \vec{\mu_c})^T \sum_{c}^{-1}(\vec{x_i} - \vec{\mu_c})\Bigr)
\end{align}
\end{document}