Skip to content

04-01: Exercises — Measures of Variation

Notes reference: 04-01: Measures of Variation


Q1: Range, variance, standard deviation by hand

Sample: 12, 15, 18, 20, 25

Compute the range, sample variance, and sample standard deviation using both formulas.

Solution

n = 5,  Σx = 90,  x̄ = 18,  Σx² = 144 + 225 + 324 + 400 + 625 = 1718

Range = 25 − 12 = 13

DEFINITION FORM
x     x − x̄     (x − x̄)²
12     −6          36
15     −3           9
18      0           0
20      2           4
25      7          49
──    ─────       ─────
90      0          98

s² = 98 / (5 − 1) = 24.5
s  = √24.5 = 4.950

COMPUTATIONAL FORM
s² = [1718 − 90²/5] / 4 = [1718 − 1620] / 4 = 98 / 4 = 24.5   ✓ same
=MAX(A2:A6)-MIN(A2:A6)      ' 13
=VAR.S(A2:A6)               ' 24.5
=STDEV.S(A2:A6)             ' 4.9497
=DEVSQ(A2:A6)               ' 98  — Σ(x − x̄)² directly

Q2: Population vs. sample

The five values in Q1 are now the entire population. Recompute σ² and σ.

Solution

σ² = 98 / 5 = 19.6
σ  = √19.6 = 4.427

Compare:  s² = 24.5,  s = 4.950     (dividing by n − 1 = 4)
          σ² = 19.6,  σ = 4.427     (dividing by N = 5)

The sample version is LARGER — that is the point of the n−1 correction.
=VAR.P(A2:A6)      ' 19.6
=STDEV.P(A2:A6)    ' 4.4272
var(x)                          # 24.5   sample (R's default)
var(x) * (5-1)/5                # 19.6   population
x.var(ddof=1)     # 24.5   sample
x.var(ddof=0)     # 19.6   population  (NumPy's default!)

Q3: Same mean, different spread

Two production lines fill bottles (ml):

Line A:  498  500  501  499  502
Line B:  480  510  495  515  500

Compute the mean and standard deviation for each. Which line would you keep?

Solution

Line A:  Σx = 2500,  x̄ = 500.0
         deviations: −2, 0, +1, −1, +2  →  Σ(x−x̄)² = 4+0+1+1+4 = 10
         s² = 10/4 = 2.5      s = 1.581

Line B:  Σx = 2500,  x̄ = 500.0
         deviations: −20, +10, −5, +15, 0  →  Σ(x−x̄)² = 400+100+25+225+0 = 750
         s² = 750/4 = 187.5   s = 13.693

IDENTICAL means, wildly different consistency.
Line A is 8.7× more consistent  →  keep Line A.

Why it matters: a customer receiving a 480 ml bottle from Line B has a legitimate complaint, even though the line averages exactly 500.


Q4: Coefficient of variation

Compare the relative variability of:

  • Daily sales: mean $4,200, s = $630
  • Daily customers: mean 185, s = 42
  • Package weight: mean 2.4 kg, s = 0.18 kg

Solution

CV_sales     =  630 / 4200  × 100 = 15.0 %
CV_customers =   42 /  185  × 100 = 22.7 %
CV_weight    = 0.18 /  2.4  × 100 =  7.5 %

Most variable (relatively):  CUSTOMER COUNT
Least variable:              PACKAGE WEIGHT

The raw standard deviations (630, 42, 0.18) cannot be compared — they are in dollars, people, and kilograms. The CV is unitless, which is exactly why it exists.

=STDEV.S(A2:A31)/AVERAGE(A2:A31)*100
from scipy import stats
stats.variation(x, ddof=1) * 100

Q5: The empirical rule

Test scores are bell-shaped with μ = 72 and σ = 8.

  1. Between what two scores do about 68% of students fall?
  2. About what percent score between 56 and 88?
  3. About what percent score above 88?
  4. A student scores 96. How unusual is that?

Solution

1.  μ ± 1σ = 72 ± 8   →  64 to 80          (about 68%)

2.  56 = 72 − 2(8)  and  88 = 72 + 2(8)   →  μ ± 2σ  →  about 95%

3.  Above 88 is the upper tail beyond +2σ.
    100% − 95% = 5% in BOTH tails  →  about 2.5% above 88.

4.  z = (96 − 72)/8 = +3.0
    μ ± 3σ covers 99.7%, so 0.3% lies in both tails, ~0.15% above +3σ.
    Roughly 1 student in 700 — VERY unusual.

Q6: Chebyshev's theorem

Delivery times have μ = 34 minutes and σ = 6 minutes. The shape is unknown and clearly skewed.

  1. At least what percent of deliveries fall between 22 and 46 minutes?
  2. At least what percent fall between 16 and 52 minutes?
  3. Within what interval do at least 84% of deliveries fall?

Solution

1.  22 = 34 − 2(6),  46 = 34 + 2(6)   →  k = 2
    1 − 1/2² = 1 − 0.25 = 0.75        →  AT LEAST 75%

2.  16 = 34 − 3(6),  52 = 34 + 3(6)   →  k = 3
    1 − 1/3² = 1 − 0.111 = 0.889      →  AT LEAST 88.9%

3.  1 − 1/k² = 0.84  →  1/k² = 0.16  →  k² = 6.25  →  k = 2.5
    34 ± 2.5(6) = 34 ± 15  →  19 to 49 minutes

Why not the empirical rule? The distribution is skewed, so the 68–95–99.7 figures do not apply. Chebyshev is weaker but always valid.


Q7: Grouped standard deviation

Class f Xm
20–29 5 24.5
30–39 12 34.5
40–49 8 44.5
50–59 5 54.5

Solution

n = 30

Σ f·Xm = 5(24.5) + 12(34.5) + 8(44.5) + 5(54.5)
       = 122.5 + 414.0 + 356.0 + 272.5 = 1165.0

x̄ = 1165.0 / 30 = 38.833

Σ f(Xm − x̄)²
  = 5(24.5−38.833)² + 12(34.5−38.833)² + 8(44.5−38.833)² + 5(54.5−38.833)²
  = 5(205.44)       + 12(18.78)        + 8(32.11)        + 5(245.44)
  = 1027.22         + 225.33           + 256.89          + 1227.22
  = 2736.67

s² = 2736.67 / 29 = 94.368
s  = √94.368 = 9.714
=SUMPRODUCT(C2:C5, D2:D5)/SUM(C2:C5)                         ' mean -> 38.833
=SQRT(SUMPRODUCT(C2:C5,(D2:D5-$G$1)^2)/(SUM(C2:C5)-1))       ' s    -> 9.714

Q8: Which spread measure?

Choose the best measure of spread and justify it.

  1. Comparing consistency of two machines filling the same product
  2. Describing the spread of household income in a country
  3. Comparing variability of stock returns (mean 8%, s 22%) against bond returns (mean 3%, s 4%)
  4. A quick sanity check on a column of 500 numbers you just imported

Solution

1. STANDARD DEVIATION  — same units, same mean; s compares directly.
2. IQR                 — income is heavily right-skewed; s is inflated by the
                         top tail, while the IQR describes the middle 50%.
3. COEFFICIENT OF VARIATION — different mean levels.
                         CV_stock = 22/8 × 100 = 275%
                         CV_bond  =  4/3 × 100 = 133%
                         Stocks carry more than twice the relative risk.
4. RANGE (min and max)  — instant, and its whole job here is to expose
                         impossible values such as age = 250 or score = −5.

⬅️ Previous: 03-02: Exercises — Weighted and Grouped Means ➡️ Next: 04-02: Exercises — Measures of Position and Outliers