◇ OpenCyber Academy
Bachelor's · Chapter 12 · English

Chapter 12 — Probability and statistics

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Chapter 12 — Probability and statistics

Lesson map

Lesson 12 published. Map, example, EX034.

flowchart TD
  N0["Learning outcomes"]
  N1["12.1 Proportions and intervals"]
  N2["Lab — Wilson interval for a reporting proportion"]
  N3["12.2 Comparing proportions"]
  N4["12.3 Small samples"]
  N5["Synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5
  N5 --> EX["Worked example"]
  EX --> Q["Exercise EX034"]

Logical drawing

flowchart LR
  N0["Learning outcomes"]
  N1["12.1 Proportions and intervals"]
  N2["Lab — Wilson interval for a reporting proportion"]
  N3["12.2 Comparing proportions"]
  N4["12.3 Small samples"]
  N5["Synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX034"]
[Learning outcomes]
    |
    v
[12.1 Proportions and intervals]
    |
    v
[Lab — Wilson interval for a reporting proportion]
    |
    v
[12.2 Comparing proportions]
    |
    v
[12.3 Small samples]
    |
    v
[Synthesis]
    |
    v
[Worked example] --> [Exercise EX034]

Learning outcomes

You will (1) estimate a proportion with a confidence interval; (2) compare two proportions cautiously; (3) explain why small samples mislead.

12.1 Proportions and intervals

Ashcombe ran an announced, staff-agreed simulation in which 120 staff received one practice email. Of these, 18 reported it within an hour. The proportion reporting is 15%. Nadia learns that a single number hides uncertainty, so she computes a 95% confidence interval using the Wilson method, which behaves well with small counts. The interval shows the range of rates consistent with the data. She reports the rate together with its interval so that managers do not treat a single estimate as exact. The interval is 9.7% to 22.5%.

Lab — Wilson interval for a reporting proportion

# Wilson 95% interval for reporting proportions (synthetic).
from math import sqrt
def wilson(k, n, z=1.96):
    p = k / n; d = 1 + z * z / n; c = (p + z * z / (2 * n)) / d; h = z * sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / d
    return c - h, c + h
for name, k, n in (("all staff", 18, 120), ("Central", 6, 30), ("Riverside", 3, 24)):
    lo, hi = wilson(k, n); print(f"{name}: {k}/{n} = {k / n:.1%}, 95% CI {lo:.1%} to {hi:.1%}")

Run with python3 lab_ci.py. Verified output:

all staff: 18/120 = 15.0%, 95% CI 9.7% to 22.5%
Central: 6/30 = 20.0%, 95% CI 9.5% to 37.3%
Riverside: 3/24 = 12.5%, 95% CI 4.3% to 31.0%

12.2 Comparing proportions

Two branches show different reporting rates: Central 6 of 30 (20%, interval 9.5% to 37.3%) and Riverside 3 of 24 (12.5%, interval 4.3% to 31.0%). Nadia compares them and finds that their intervals overlap heavily. The apparent difference could easily arise by chance. She resists the temptation to praise one branch and criticise the other. Comparing groups fairly requires attention to sample size, and in human factors work it also requires care, because public comparisons between teams can create pressure and resentment that damage the reporting culture the programme seeks to build.

12.3 Small samples

With small branches, one person's action changes the rate greatly. At Quay, with five staff, one extra report moves the rate by twenty points. Nadia explains this to managers using the lab output and suggests reporting branch results only when at least twenty staff are included, or combining small branches. This rule protects both the accuracy of the figures and the privacy of staff in small teams, where individual actions could otherwise be guessed from a group rate. Managers accept the rule.

Worked example

Nadia computes a Wilson interval for 18 of 120, compares two branches cautiously and sets a minimum group size of twenty.

Synthetic case. Data are synthetic.

Errors and limits

Intervals assume independent responses. One simulation is a single snapshot.

Exercises

Synthesis

Proportions need intervals, comparisons need care and small groups need protecting.

Continue studying — chapter 12 of 40

← Chapter 11 (draft) · Course chapter index · Chapter 13 (draft) →