[Tex/LaTex] Variance formula does not display correctly

math-mode

\begin{document}
\sigma^2=\frac{\sum(X -\mu)^2}\limits_{i=1}^N{N}
\end{document}

This is the code I am using to display variance formula, but it displays
enter image description here
instead of

enter image description here

How should I correct it?

Best Answer

Your MWE can not work! For math expression you need math environment, for inline formulas $ ... your math expression ...$, for display formula (stand alone in text) \begin{equation} .... \end{equation} for numbered equations and for non-numbered \[ ... \]. For math environments exist other possibilities, which available with us packets as amsmath etc.

Also the formula is ill formed. Correct code is:

\documentclass[border=3mm,
               preview]{standalone}% or any other document class, as article, book ..
\begin{document}
$\sigma^2 = \frac{\sum\limits_{i=1}^N (X -\mu)^2}{N}$
\end{document}

which gives:

enter image description here

Related Question