Sample variance and standard deviation

The sample variance of given numbers x_1,ldots,x_n, is defined as

 sigma^2 := frac{1}{n} left( (x_1-hat{x})^2 + ldots + (x_n-hat{x})^2 right) ,

where hat{x} is the sample average of x_1,ldots,x_n. The sample variance is a measure of the deviations of the numbers x_i with respect to the average value hat{x}.

The sample standard deviation is the square root of the sample variance, sigma^2. It can be expressed in terms of the Euclidean norm of the vector x = (x_1,ldots,x_n), as

 sigma = frac{1}{sqrt{n}} | x - hat{x} mathbf{1} |_2,

where |cdot|_2 denotes the Euclidean norm.

More generally, for any vector p in mathbf{R}^n, with p_i ge 0 for every i, and p_1+ldots+p_n = 1, we can define the corresponding weighted variance as

 sum_{i=1}^n p_i (x_i - hat{x})^2.

The interpretation of p is in terms of a discrete probability distribution of a random variable X, which takes the value x_i with probability p_i, i=1,ldots,n. The weighted variance is then simply the expected value of the squared deviation of X from its mean mathbf{E} X, under the probability distribution p.

See also: sample and weighted average.