# Statistics - (Variance|Dispersion|Mean Square) (MS)

The variance shows how widespread the individuals are from the average.

The variance is how much that the estimate varies around its average.

It's a measure of consistency. A very large variance means that the data were all over the place, while a small variance (relatively close to the average) means that the majority of the data are closed.

See:

## Formula

$$\begin{array}{rrl} Variance & = & \frac\sum_{i=1}^{\href{sample_size}{N}}{(\href{raw_score}{X}_i- \href{mean}{\bar{X}})^2}}\href{degree_of_freedom}{\text{Degree of Freedom}}} \\ & = & \frac\sum_{i=1}^{\href{sample_size}{N}}{(\href{Deviation Score}{\text{Deviation Score}}_i)^2}}\href{degree_of_freedom}{\text{Degree of Freedom}}} \\ & = & (\href{Standard_Deviation}{\text{Standard Deviation}})^2 \end{array}$$

where:

$$Var(X + Y) = Var(X) + Var(Y) + 2 Cov(X, Y)$$ where:

## Computation

### Python

units = [7, 10, 9, 4, 5, 6, 5, 6, 8, 4, 1, 6, 6]

def units_average(units):
average = sum(units) / len(units)
return average

def units_variance(units,average):
diff = 0
for unit in units:
diff += (unit - average) ** 2
return diff / len(units)

print units_variance(units, units_average(units))

5