A variance2) 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 = Σ(x2) / N - μ2

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

σ2 = Σ(x2) / 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 Σ(x2) and then put those values (along with N) into the above equation at the end.)