Variance and Standard Deviation
What You'll Learn
- 1Explain why squared deviations are averaged instead of raw deviations
- 2Derive the direct method from the definition and the short-cut method by a change of origin
- 3Handle frequency tabulated data by weighting both sums
- 4Compare two data sets with the coefficient of variation and correct a wrong observation
Two classes can share a mean and still look completely different: one clusters tightly around it, the other scatters to both extremes. The mean alone cannot see that difference, so a second quantity is needed, and the average of the deviations themselves fails because positive and negative spreads cancel. Squaring the deviations removes the cancellation, averaging them gives a single number, and taking the square root returns the answer to the original units. This lesson derives that number from first principles, shows how a change of origin simplifies the arithmetic, and solves four problems of the kind set in board papers.
From the definition to the formula
Let have mean . The natural candidate for a spread measure is the mean absolute deviation , and it is perfectly usable, but the absolute value is not differentiable and does not decompose algebraically. The variance squares instead:
Expanding the square gives . Summing term by term produces , and since the middle term is , which cancels all but one copy of . Dividing by yields the direct method:
The rearrangement is worth keeping, because questions about a wrong observation use exactly that identity to recover the sum of squares. The standard deviation is then , which carries the same physical unit as the data â centimetres in, centimetres out.
Changing the origin: the short-cut method
Subtracting a convenient assumed mean from every value gives deviations . The variance of the shifted data equals the variance of the original data, because adding or subtracting a constant shifts every value and the mean by the same amount and leaves all deviations untouched. Applying the direct method to the therefore gives
When is chosen near the middle of the data the deviations are small integers, their squares are trivial to add, and the mean deviation is usually a clean number or zero. A third variant, the step-deviation method, divides the deviations by a common factor and multiplies the final variance by , which is worth using only when every value shares that factor.
| Method | Formula | Best used when | What you must tabulate |
|---|---|---|---|
| Direct | mean of minus mean squared | values are small and the mean is whole | and |
| Short-cut | mean of minus mean of squared | values are large or the mean is fractional | and |
| Step-deviation | short-cut result times | values share a common difference | and |
| Frequency weighted | mean of minus mean squared | values repeat with tabulated frequencies | , and |
| Mean absolute deviation | mean of | the question explicitly asks for it | absolute deviations only |
Properties that save time
Adding a constant to every observation leaves both the mean and the standard deviation unchanged: the whole distribution slides and its spread does not alter. Multiplying every observation by multiplies the mean by and the standard deviation by , so the variance grows by . Dividing by scales both the mean and the standard deviation by the same factor, which is why the coefficient of variation,
is invariant under a change of units. A data set measured in grams and the same data set measured in kilograms have identical coefficients of variation, and that is precisely what makes the coefficient the right tool for comparing consistency across sets of different sizes or means.
First pair of numerical problems
Second pair of numerical problems
How CBSE frames statistics questions
One mark questions give a tiny data set and ask for the standard deviation, or ask which property holds when every observation is multiplied by a constant. Three and four mark questions come in three recurring shapes: a frequency table that must be weighted, a comparison of two groups where the coefficient of variation decides the answer, and the wrong-observation correction of Example 4. In the correction type the marking scheme explicitly wants the identity written down before substitution, because it shows where the second total came from. Common failures are dividing the sum of squares by the number of classes rather than by the number of observations, mixing a frequency with an unfrequencyed term in the same sum, and quoting the variance when the question asked for the standard deviation.
Verifying the arithmetic in Python
The first script computes the variance by both methods and asserts that they agree, which is the fastest way to catch a tabulation slip.
def mean(values):
return sum(values) / len(values)
def variance_direct(values):
m = mean(values)
return sum(v * v for v in values) / len(values) - m * m
def variance_shortcut(values, A):
devs = [v - A for v in values]
return sum(d * d for d in devs) / len(devs) - (sum(devs) / len(devs)) ** 2
data = [3, 5, 7, 9, 11]
print("mean :", mean(data))
print("direct var :", variance_direct(data))
print("shortcut var:", variance_shortcut(data, A=7))
assert abs(variance_direct(data) - variance_shortcut(data, 7)) < 1e-12
print("standard dev:", variance_direct(data) ** 0.5)
The second script confirms the shift and scale properties and walks through the correction problem of Example 4.
base = [10, 20, 30, 40, 50]
scaled = [3 * v + 7 for v in base]
def sd(xs):
m = sum(xs) / len(xs)
return (sum((x - m) ** 2 for x in xs) / len(xs)) ** 0.5
print("sd original :", round(sd(base), 6))
print("sd shifted :", round(sd([v + 7 for v in base]), 6))
print("sd scaled :", round(sd(scaled), 6), "expected", 3 * sd(base))
n, old_mean, old_sd = 20, 10, 5
total = n * old_mean
total_sq = n * (old_sd ** 2 + old_mean ** 2)
total_sq -= 25 ** 2 - 5 ** 2
total += -25 + 5
print("corrected mean:", total / n)
print("corrected sd :", (total_sq / n - (total / n) ** 2) ** 0.5)
The shifted standard deviation is bit-for-bit identical to the original, the scaled one is exactly three times larger, and the corrected totals reproduce a mean of with a standard deviation of .
Common Mistakes
Dividing the sum of squares by the wrong count
Fix: Use the number of observations: in frequency data that is the sum of the frequencies, not the number of distinct values.
Applying the short-cut formula but forgetting the correction term
Fix: The formula is mean of d squared minus the square of mean d, so if the assumed mean is not the true mean the second term must still be subtracted.
Comparing consistency with standard deviations instead of coefficients
Fix: A set with mean 100 and spread 15 is more consistent than one with mean 50 and spread 10, because 15 percent beats 20 percent in the coefficient.
Key Takeaways
- Variance is the mean of the squared deviations, and expanding those squares gives the direct method mean of x squared minus mean squared
- A change of origin leaves the variance untouched, which is why the short-cut method may assume any convenient value of A
- Multiplying data by a constant multiplies the standard deviation by that constant but leaves the coefficient of variation unchanged
- The identity sum of x squared equals n times variance plus mean squared is the key to correcting a wrongly recorded observation