Lesson map
Lesson 05. Map, example, EX051.
flowchart TD
K["k and n enter wilson"] --> P["Printed rate is k/n to three decimals"]
P --> D["Denominator grows with n"]
D --> W["The bracket gets narrower"]
Three rows share 0.150. Their brackets do not.
Logical drawing
successes=3/20 rate=0.150 wilson95=[0.052, 0.360]
successes=30/200 rate=0.150 wilson95=[0.107, 0.206]
successes=300/2000 rate=0.150 wilson95=[0.135, 0.166]
Learning outcomes
After this chapter, you should be able to:
- Read 0.150 as k divided by n, rounded to three decimals.
- Name the three printed brackets and which n produced each one.
- Refuse a note that keeps 0.150 and drops the bracket.
5.1 The function fixes z at 1.96 and puts n in the denominator.
wilson(k, n) sets p = k/n and z = 1.96. It then builds d = 1 + z*z/n. The centre is (p + z*z/(2*n)) / d. The half-width is z times a square root, and that whole term is divided by the same d. The print shows k/n with three decimals, then the lower and upper ends with three decimals. It does not print the centre by itself.
For the pairs (3, 20), (30, 200) and (300, 2000), k/n is exactly 0.15, so every rate column shows 0.150. The brackets are [0.052, 0.360], [0.107, 0.206] and [0.135, 0.166]. Subtracting the first lower end from its upper end leaves a wide gap; subtracting 0.135 from 0.166 leaves a tight one. Only the trial count moved.
Lesson table; scroll horizontally to read all columns →
| What the row holds fixed | What moves when n grows |
|---|---|
| z stays 1.96 | d gets closer to 1 |
| printed rate stays 0.150 | half-width shrinks |
| three-decimal rounding | the bracket tightens around 0.150 |
This is a Wilson interval on independent yes-or-no draws. It is not a Wald interval centred only on p. Raising z, or swapping in a different formula, would be a different script. This file does neither.
5.2 Worked example
Lesson table; scroll horizontally to read all columns →
| Note on Omar's desk | Verdict | Reason |
|---|---|---|
| "Lab S found 15 percent." | Incomplete | Three denominators share that rate |
| "3/20 and the bracket 0.052 to 0.360." | Keep | That is the first printed row |
| "300/2000 narrowed it to 0.135–0.166." | Keep | That is the third printed row |
| "Average the three brackets." | Refuse | No fourth row exists |
Synthetic case. Tallis & Co did not run this count on client mail. The three rows are the lab's own trials.
Errors and limits
Quoting 0.150 without its n pretends the three rows are one measurement. They are one rate printed three times.
Apply
- EX051 — Three widths. The lab prints rate 0.150 on 3/20, 30/200 and 300/2000. Which bracket belongs to which denominator, and may a note keep only 0.150?
Show marking criteria
Rubric: 3 = [0.052, 0.360], [0.107, 0.206], [0.135, 0.166] in that order; z stays 1.96; dropping the bracket hides the width;; 2 = the three brackets stay in order;; 1 = the rate only;; 0 = a new interval.