# Mean and Variance

## Basics

Given $n$ values of $x$

\begin{alignedat}{1} & X = \lbrace x_1, x_2, ... x_n\rbrace \end{alignedat}

Mean of $x$:

\begin{alignedat}{1} & \mu_x = \frac 1 n \sum_{i=1}^{n}x_i \end{alignedat}

Variance of $x$:

\begin{alignedat}{1} & \sigma_x\,^2 = \frac 1 n \bigg[ \sum_{i=1}^{n}(x_i - \mu_x )^2 \bigg] \end{alignedat}

Standard Deviation of $x$:

\begin{alignedat}{1} & \sigma_x = \sqrt{\frac 1 n \bigg[ \sum_{i=1}^{n}(x_i - \mu_x )^2 \bigg]} \end{alignedat}

## Mean centring

Example

Given this set of values:

\begin{alignedat}{1} Z &= \lbrace 1,5,12\rbrace \\ \\ \mu_z &= 6 \\ \\ \sigma_z\,^2 &= \frac 1 3 \centerdot (25 + 1 + 36 ) \\ \\ &= 20.667 \end{alignedat}

Now subtract the mean from each value:

\begin{alignedat}{1} \\ Z' &= \lbrace 1-6,5-6,12-6\rbrace \\ & = \lbrace -5,1,6\rbrace \\ \\ \mu_z' &= 0 \\ \\ \sigma_z\,^2 &= \frac 1 3 \centerdot (25 + 1 + 36 ) \\ \\ &= 20.667 \end{alignedat}

So mean-centring shifts the data horizontally along $\R$ but doesn't change the variance

Based on course material by Paul Bendich and Daniel Egger from Data Science Maths Skills