Variance measures how spread out data points are from their average (mean). To calculate it, find the mean first, then measure how far each data point deviates from that mean, square those deviations, and average them.
Step-by-step process:
-
Calculate the mean: Add all data points and divide by how many points there are. For example, with values [2, 4, 6, 8], the mean is (2+4+6+8)/4 = 5.
-
Find deviations: Subtract the mean from each data point. Using the example: (2-5)=-3, (4-5)=-1, (6-5)=1, (8-5)=3.
-
Square each deviation: (-3)²=9, (-1)²=1, (1)²=1, (3)²=9.
-
Average the squared deviations: (9+1+1+9)/4 = 5. This is the variance.
Formula: For a population, variance = Σ(x - mean)² / N, where N is the number of data points. For a sample, divide by (N-1) instead of N to get an unbiased estimate.
The reason for squaring is to penalize larger deviations more heavily and eliminate negative signs that would cancel out. Variance is expressed in squared units (e.g., if your data is in meters, variance is in meters²). If you want the spread in original units, take the square root of variance to get standard deviation.