Statistics Notation in LaTeX: Mean, Variance and Sigma

Which sigma means sum and which means population spread, how x̄ is built, and why estimators carry a hat.

Statistics notation is a case study in one letter carrying two jobs: \sigma is a standard deviation and \sum is a summation, while \bar is an accent rather than a line. Whether a formula is about a sample or a population is decided by which letter you type; whether the mark looks right is decided by accent width. The two pages this one leans on are Math Accents and Summation.

Which one to use

Situation Write this Because
Sample mean
\bar{x}
Accent, fixed width.
Mean of a long name
\overline{x_i}
Overline stretches to the span.
Population mean
\mu
Greek letter, not a bar.
Sample variance
s^2
Latin letter, squared.
An estimator
\hat{\theta}
The hat marks an estimate.
Standard deviation
\sigma, s
Same family, different level.

The commands

What Type this Renders as
Sample mean The bar is an accent command; \overline{x} draws a wider rule but is meant for overlines in complex conjugates.
\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i
\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i
Population mean Greek letter for the parameter, Latin-with-bar for the statistic computed from data.
\mu = \frac{1}{N}\sum_{i=1}^{N} x_i
\mu = \frac{1}{N}\sum_{i=1}^{N} x_i
Sample variance The n−1 divisor is Bessel correction, and it sits inside the fraction rather than under the sum.
s^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar{x})^2
s^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar{x})^2
Population variance Same structure, Greek parameter, N observations.
\sigma^2 = \frac{1}{N}\sum_{i=1}^{N}(x_i - \mu)^2
\sigma^2 = \frac{1}{N}\sum_{i=1}^{N}(x_i - \mu)^2
Standard deviation The root of the variance; nothing special beyond \sqrt.
\sigma = \sqrt{\sigma^2}
\sigma = \sqrt{\sigma^2}
Summation shorthand Capital Greek \Sigma is sometimes typed as the sum operator in older texts; \sum is the correct operator.
\sum x_i \quad \sum x_i^2 \quad \Sigma X
\sum x_i \quad \sum x_i^2 \quad \Sigma X
Frequency weighting Grouped data: f is a subscript label, so it stays italic as a variable.
\bar{x} = \frac{\sum f_i x_i}{\sum f_i}
\bar{x} = \frac{\sum f_i x_i}{\sum f_i}
Estimator hat A hat universally means "this is an estimate of the thing underneath it".
\hat{\mu} \quad \hat{p} = \frac{x}{n}
\hat{\mu} \quad \hat{p} = \frac{x}{n}
Expected value Blackboard E is the modern convention; \mathrm{E} is the conservative one.
\mathbb{E}[X] = \sum_x x\,P(X=x)
\mathbb{E}[X] = \sum_x x\,P(X=x)
Z-score Standardising a single observation, which is where the Greek/Latin distinction becomes load-bearing.
z = \frac{x - \mu}{\sigma}
z = \frac{x - \mu}{\sigma}

Worked examples

Variance in one-line shortcut form

\sigma^2 = \frac{\sum x_i^2}{n} - \mu^2
\sigma^2 = \frac{\sum x_i^2}{n} - \mu^2

The computational form still taught in syllabuses; identical value, easier arithmetic.

Mean and deviation together

\bar{x} = 12.4, \qquad s = 1.8
\bar{x} = 12.4, \qquad s = 1.8

Reporting results with the comma-separated pair, using \quad because a plain space collapses.

Correlation coefficient

r = \frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum (x_i-\bar{x})^2 \sum (y_i-\bar{y})^2}}
r = \frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum (x_i-\bar{x})^2 \sum (y_i-\bar{y})^2}}

Deeply nested accents inside a fraction — the case where \dfrac or display maths stops the inner terms crushing.

Distribution shorthand

\bar{X} \sim N\left(\mu, \frac{\sigma^2}{n}\right)
\bar{X} \sim N\left(\mu, \frac{\sigma^2}{n}\right)

Sampling distribution of the mean, tilde-style \sim read as "is distributed as".

Common mistakes

  • Using \Sigma where \sum is meant. The first is a capital letter sized like text; the second is the big operator that carries bounds.
  • Writing x_bar or x̄ copied from a PDF. Use \bar{x}; the pasted combining character breaks in most editors.
  • Setting n and N in the same formula without deciding which is the sample and which the population. Case carries the meaning.
  • Typing Var(x) and mean(x) as words. They print as italic products; use \mathrm{Var} or \operatorname{Var}.

Questions about this notation

What is the difference between \sum and \sigma?
None in origin, total in usage. \sum is the n-ary addition operator that takes lower and upper bounds; \sigma is the lowercase Greek letter used as a name for standard deviation. They occupy different grammatical roles in a formula.
How do I write x bar in LaTeX?
\bar{x} for a single character, \overline{AB} when the rule has to span several. For a mean of a multi-token expression, \bar{x} is normal and the braces keep only the x under the accent.
Should sample statistics be lowercase?
Yes, by convention: \bar{x}, s^2 and n describe your data; \mu, \sigma^2 and N describe the population. Uppercase X and Y denote random variables rather than observed values, which is why \bar{X} appears in sampling theory.
How do I write expectation, variance and standard deviation as proper operators?
\mathbb{E}[X] is the usual expectation and needs amssymb for the blackboard bold. Variance and standard deviation are not core commands: declare them once with \DeclareMathOperator{\Var}{Var} from amsmath, so they print upright with operator spacing instead of looking like a product of separate variables.

Keep reading

Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.