\documentclass{amsart}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{float}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\graphicspath{ {./images/} }
\begin{document}
\section{The Binomial Distribution}
If $X \sim Bin(n,p)$ where $p = \frac{1}{2}$, hence $q = 1 - \frac{1}{2} = \frac{1}{2}$, then
\begin{align*}
P(X=k) &= {n\choose k}p^k q^{n-k}\\
&= {n\choose k}{\frac{1]{2}}^k \frac{1]{2}^{n-k}\\
&= {n\choose k}{\frac{1]{2}}^n\\
&= \frac{n\choose k}{2^n}
\end{align*}
Note that $2^n$ is constant for fixed $n$. Therefore, $P(X=k)$ has symmetry matching the symmetry of Pascal's Triangle.
If $p < \frac{1}{2}$, the distribution is negatively skewed.
\begin{align*}
P(X=k) &= {n\choose k}p^k q^{n-k}\\
&= {n\choose k}{\frac{1]{6}}^k \frac{5]{6}^{n-k}\\
&= \frac{n\choose k 5^{n-k}}{6^n}
\end{align*}
\end{document}
所以从 \section{二项分布} 开始似乎有问题。以前我排版时,它一直说“插入了缺失的 $”,我试了一下,不幸的是弄乱了太多,现在它只显示“未定义的控制序列 \document class{amsart}”作为错误消息。请帮忙!
后续问题
这是我的全部代码(不包括我认为不会导致错误的信息):
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{float}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\graphicspath{ {./images/} }
\begin{document}
1. $\frac{(n\times p)!}{p!^n}$
\vspace{5mm}
2. Want to borrow $1$ to $n$ books:\\
There are $38$ numbers and only $26$ differences when maximised, so the ceiling function $\lceil \frac{38}{26} \rceil =2$.\\
Therefore by PHP, there exists at least two numbers whose difference is at most $26$
\section{Statistics}
\subsection{Averages from grouped data}
\hfill\\
\textbf{Estimating the mean:} An estimate for the mean can be obtained by assuming hat each of the raw data values takes the midpoint value of the interval in which it has been placed
$$\text{Mean estimate} =\frac{\sum{fx}}{\sum{f}}$$
\subsection{Pareto Charts}
\hfill\\
The following table shows the 6 most common reasons for conditions failing their driving test.\\
\hfill\\
\begin{center}
\begin{tabular}{@{}lll@{}}
\toprule
Reason & Percentage of conditions & Cumulative frequency \\ \midrule
Observations at junctions & 11.9 & 31 \\
Use of mirrors & 8.2 & 52.4 \\
Inappropriate speed & 5.1 & 65.7 \\
Steering control & 4.7 & 77.9 \\
Reversing around corner & 4.3 & 89.1 \\
Incorrect positioning & 4.2 & 100 \\ \bottomrule
Total &38.4 \\
\end{tabular}
\end{center}
\hfill \\
\begin{figure}[H]
\centering
\includegraphics[scale=0.15]{paretochart1}
\caption{Pareto chart}
\label{default}
\end{figure}
\newpage
\textbf{Note:}
\begin{itemize}
\item The Cumulative frequency graph is concave down and monotone increasing
\item Pareto Principle: 80\% of consequences come from 20\% of the causes
\item Deciles:
\begin{itemize}
\item 0 - 10\% 1st decile
\item 10 - 20\% 2nd decile
\item $\vdots$
\item 90 - 100\% 10th decile
\end{itemize}
\end{itemize}
\section{The Binomial Distribution}
If $X \sim Bin(n,p)$ where $p = \frac{1}{2}$, hence $q = 1 - \frac{1}{2} = \frac{1}{2}$, then
\begin{align*}
P(X=k) &= {n\choose k}p^k q^{n-k}\\
&= {n\choose k}{\frac{1}{2}}^k \frac{1}{2}^{n-k}\\
&= {n\choose k}{\frac{1}{2}}^n\\
&= \frac{{n\choose k}}{2^n}
\end{align*}
Note that $2^n$ is constant for fixed $n$. Therefore, $P(X=k)$ has symmetry matching the symmetry of Pascal's Triangle.
If $p < \frac{1}{2}$, the distribution is negatively skewed.
\begin{align*}
P(X=k) &= {n\choose k}p^k q^{n-k}\\
&= {n\choose k}{\frac{1}{6}}^k \frac{5}{6}^{n-k}\\
&= \frac{{n\choose k 5^{n-k}}}{6^n}
\end{align*}
Note that $5^{n-k}$ does affect the symmetry. If $k$ is small, probabilities to left of the mode are higher. If $k$ is large, probabilities to the right of the mode are lower.
\end{document}
答案1
(这个答案回答的是 OP 的后续问题,而不是最初提出的问题。)
关于您的代码的一些一般观察:
在 LaTeX 文档中,不应使用
{n \choose k}
或{1 \over 2}
中缀样式的符号。句号。相反,应分别使用\binom{n}{k}
和\frac{1}{2}
。有关此主题的更多信息,请参阅\over
和有什么区别\frac
?在 LaTeX 文档中,不要使用
$$
来启动和终止显示数学模式。而是使用\[
和\]
。有关详细讨论,请参阅为什么\[ ... \]
优于$$ ... $$
?代码中存在过多的视觉格式指令。在大多数情况下,它们不会导致错误,但它们往往是多余的,并且会造成大量代码混乱。例如,大多数指令
\hfill\\
都可以用简单的空行替换。同样,运行文本中的大多数\\
行终止符可以且应该被删除。诸如 之类的符号
{\frac{1}{2}}^k
不利于良好的排版。首先,周围的花括号\frac{1}{2}
是多余的。其次,更重要的是,\frac{1}{2}^k
和之间几乎没有视觉差异\frac{1^k}{2}
。由于后者的印象显然应该不惜一切代价避免,请开始写(在显示数学上下文中)\biggl(\frac{1}{2}\biggr)^{\!k}
。您的读者会非常感激的。不要在显示数学材料之前创建段落分隔符。
请将看起来小巧的构造(如 和 )替换为更易于读者理解的构造(如 和 ),让您的读者(在视觉上)得到
\frac{{n\choose k}}{2^n}
休息\frac{\binom{n}{k 5^{n-k}}}{6^n}
。\binom{n}{k}2^{-n}
试试看\frac{\binom{n}{k 5^{n-k}}}{6^n}
!
附录回答 OP 的后续问题,关于为什么我称之为\frac{{n\choose k}}{2^n}
“看起来很小”,以及为什么我建议改用\binom{n}{k}2^{-n}
。毕竟,它们不是一样吗数学上? 当然,从数学上讲,它们是相同的;然而,它们根本不一样印刷上。TeX 和 LaTeX 是印刷工具,因此请充分利用它们来最大限度地提高您所写内容的可读性。
\documentclass{article}
\usepackage{amsmath} % for \binom macro
\begin{document}
\[
\frac{{n\choose k}}{2^n} \quad\text{vs.}\quad \binom{n}{k}2^{-n}
\]
\end{document}
答案2
有两个问题:一个问题是多个实例的\frac{1]
分隔符不匹配,语法类似\frac{n\choose k}{2^n}
。显然,它需要一组额外的括号来消除混淆。
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{float}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
% \graphicspath{ {./images/} }
\begin{document}
\section{The Binomial Distribution}
If $X \sim Bin(n,p)$ where $p = \frac{1}{2}$, hence $q = 1 - \frac{1}{2} = \frac{1}{2}$, then
\begin{align*}
P(X=k) &= {n\choose k}p^k q^{n-k}\\
&= {n\choose k}{\frac{1}{2}}^k \frac{1}{2}^{n-k}\\
&= {n\choose k}{\frac{1}{2}}^n\\
&= \frac{{n\choose k}}{2^n}
\end{align*}
Note that $2^n$ is constant for fixed $n$. Therefore, $P(X=k)$ has symmetry matching the symmetry of Pascal's Triangle.
If $p < \frac{1}{2}$, the distribution is negatively skewed.
\begin{align*}
P(X=k) &= {n\choose k}p^k q^{n-k}\\
&= {n\choose k}{\frac{1}{6}}^k \frac{5}{6}^{n-k}\\
&= \frac{{n\choose k 5^{n-k}}}{6^n}
\end{align*}
\end{document}
答案3
如果你正在使用,format=pdftex
那么不要在文档中使用 LaTeX 的构造,即不要使用任何宏,如\documentclass
、等\usepackage
。\begin{document}
只使用普通的 TeX。它比使用 LaTeX 简单得多。