A

**variance** (σ

^{2}) is a measure of how spread out a

distribution is. It is computed as the average squared

standard deviation (σ) of each number from its mean.

σ^{2} = Σ((x - μ)^{2}) / N

Where μ is the mean, and N is the number of elements in the set. It can also be expressed as:

σ^{2} = Σ(x^{2}) / N - μ^{2}

And, if you want to substitute in the definition of the mean:

σ^{2} = Σ(x^{2}) / N - (Σx / N)^{2}

This last definition is useful for calculating the variance on the fly from a supplied series of elements, without having to store them in a list or array. (ie, you can keep a running total of Σx and Σ(x^{2}) and then put those values (along with N) into the above equation at the end.)