How to write the following probability density function for gaussian distribution in Latex (Matplotlib)
p(x) = \frac{1}{\sqrt{ 2 \pi \sigma^2 }} e^{ - \frac{ (x - \mu)^2 } {2 \sigma^2} },
How to write the following probability density function for gaussian distribution in Latex (Matplotlib)
p(x) = \frac{1}{\sqrt{ 2 \pi \sigma^2 }} e^{ - \frac{ (x - \mu)^2 } {2 \sigma^2} },
I can think of at least three ways of writing the Gaussian pdf. In the following screenshot, the first row employs \frac notation, while the second uses inline-math style "slash" fraction notation. Both rows use \exp to generate "exp". The third row uses e^{...} notation, which IMNSHO opinion doesn't look so great if the material in the exponent contains more than justa couple of symbols.
\documentclass{article}
\usepackage{amsmath} % for 'align*' environment
\begin{document}
\begin{align*}
p(x;\mu,\sigma^2)
&= \frac{1}{\sqrt{ 2 \pi \sigma^2 }} \exp\biggl( - \frac{ (x - \mu)^2 } {2 \sigma^2} \biggr) \\[1ex]
&= (2 \pi \sigma^2 )^{-0.5} \exp\bigl(-(x - \mu)^2/(2 \sigma^2)\bigr)\\
&= (2 \pi \sigma^2 )^{-0.5} \, \mathrm{e}^{-(x - \mu)^2/(2 \sigma^2)}
\end{align*}
\end{document}