[Tex/LaTex] How to write PDF of normal distribution

equationserrorsmath-mode

enter image description here

I can't seem to get the PDF of normal distribution in Latex. 🙁 This is the code I've written. How should I make it equal the picture?

\frac1{\sqrt{2\pi\sigma^2}}{exp}^\frac{x-\mu}{\sigma}

Best Answer

One of the (many!) aspects that makes TeX and LaTeX (and friends) so useful for writing mathy stuff is that there are two fundamental math modes -- inline-style math and display-style math -- and that it's very easy to switch from one mode to the other. The following screenshots shows the same formula (the pdf of a normal distribution) twice: First in inline math mode (aka text-style math mode), then in display-math mode. Observe that the code uses $ ... $ to get in and out of inline-math mode and \[ ... \] to enter and exit display-math mode.

enter image description here

\documentclass{beamer}
\newcommand{\pdf}{%
  f(x) = \frac{1}{\sigma\sqrt{2\pi}} 
  \exp\left( -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^{\!2}\,\right)
}
\begin{document}
\begin{frame}
Inline-style math mode: $\pdf$

\bigskip
Display-style math mode:
\[ \pdf \]
\end{frame}
\end{document}