Chapter 7 — Probability and statistics
Lesson map
Lesson 07 published. Map, example, EX019.
flowchart TD
N0["Learning outcomes"]
N1["7.1 A sensitive question"]
N2["7.2 Estimating the share"]
N3["7.3 The cost of deniability"]
N4["7.4 Honest answers as the real gain"]
N5["Lab — Randomised response survey on medication adher"]
N6["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6
N6 --> EX["Worked example"]
EX --> Q["Exercise EX019"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["7.1 A sensitive question"]
N2["7.2 Estimating the share"]
N3["7.3 The cost of deniability"]
N4["7.4 Honest answers as the real gain"]
N5["Lab — Randomised response survey on medication adher"]
N6["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> Q["EX019"]
[Learning outcomes]
|
v
[7.1 A sensitive question]
|
v
[7.2 Estimating the share]
|
v
[7.3 The cost of deniability]
|
v
[7.4 Honest answers as the real gain]
|
v
[Lab — Randomised response survey on medication adher]
|
v
[Synthesis]
|
v
[Worked example] --> [Exercise EX019]
Learning outcomes
You will (1) apply randomised response to a sensitive survey; (2) estimate a proportion and its uncertainty; (3) explain the privacy-accuracy trade-off.
7.1 A sensitive question
Pellmore wants to know how many patients skip prescribed medication, but patients may not answer honestly if they fear their doctor will see. Zara proposes randomised response, a classic survey technique. Each patient privately flips a coin: on heads they answer truthfully, on tails they flip again and answer yes on heads and no on tails. Any single yes might be the coin, so no answer reveals the truth about any individual, yet the overall proportion can still be estimated from many answers because the coin's behaviour is known.
7.2 Estimating the share
The lab simulates 2,000 patients, of whom 17.9% truly skip medication. With the coin design, a quarter of all answers are random yeses, so the observed share of yes answers is 0.344. The estimate subtracts the random part and doubles the remainder, giving 0.189 with a 95% interval from 0.147 to 0.231. The interval contains the true value. Zara explains each step to Pellmore's clinical lead, emphasising that the estimate describes the group and that individual answers remain deniable even to the survey team. The clinical lead accepts the method for the pilot survey.
7.3 The cost of deniability
Privacy has a price in accuracy. A direct survey of 2,000 honest respondents would have a standard error of 0.009, but randomised response has 0.021, more than twice as large. Zara explains that the noise that protects individuals also blurs the estimate, so a larger sample is needed for the same precision. This is the same trade-off she will meet in differential privacy, where randomised response is often presented as an early example of a mechanism that gives each respondent plausible deniability. Noise widens the estimate's error.
7.4 Honest answers as the real gain
Zara also notes that the comparison with a direct survey assumes patients would answer honestly, which is exactly what Pellmore doubts. If fear makes many patients deny skipping medication, a direct survey would be precise but wrong. Randomised response trades precision for honesty. She recommends it for this question and writes a short consent explanation so that patients understand the coin mechanism. Prof. Holm adds that statistics is not only about calculating intervals but about understanding how data were generated and what could bias them.
Lab — Randomised response survey on medication adherence
# Randomised response: estimate how many of 2,000 synthetic patients skipped medication, without learning anyone's answer.
import random
r = random.Random(4)
true_p, n = 0.18, 2000
truth = [r.random() < true_p for _ in range(n)]
# each respondent flips a coin: heads answer truthfully, tails answer "yes" with probability 1/2
ans = [t if r.random() < 0.5 else (r.random() < 0.5) for t in truth]
y = sum(ans) / n
est = (y - 0.25) / 0.5
se = (y * (1 - y) / n) ** 0.5 / 0.5
print(f"true share {sum(truth)/n:.3f}; observed yes {y:.3f}; estimate {est:.3f} (95% CI {est-1.96*se:.3f} to {est+1.96*se:.3f})")
print(f"direct-survey standard error would be {(est*(1-est)/n)**0.5:.3f}; randomised response {se:.3f}")
Run with python3 lab_rr.py. Verified output:
true share 0.179; observed yes 0.344; estimate 0.189 (95% CI 0.147 to 0.231)
direct-survey standard error would be 0.009; randomised response 0.021
Worked example
Zara estimates medication skipping at 0.189 (95% interval 0.147 to 0.231) against a true 0.179, and shows the standard error rising from 0.009 to 0.021 as the price of deniability.
Synthetic case. Patients and answers are synthetic and seeded.
Errors and limits
The method protects against the survey holder only if patients trust the coin; poor explanation undermines it.
Exercises
- EX019 — Deniability. Why does a single yes not reveal a patient's behaviour? Rubric: 3 = it may come from the coin rather than the truth;; 2 = mentions randomness;; 1 = says it reveals;; 0 = none.
- EX020 — Estimate computation. How is the estimate 0.189 derived from 0.344? Rubric: 3 = subtract the 0.25 random yeses and divide by 0.5;; 2 = describes partly;; 1 = wrong;; 0 = none.
- EX021 — Error ratio. How much larger is the randomised-response standard error? Rubric: 3 = 0.021 versus 0.009, more than twice;; 2 = mentions larger;; 1 = wrong;; 0 = none.
Synthesis
Chapter 7 shows privacy-accuracy trade-offs in a survey. Chapter 8 looks at hardware where data live.
Continue studying — chapter 07 of 50
← Chapter 06 (draft) · Course chapter index · Chapter 08 (draft) →