<a id="ch-06"></a>

## Chapter 6 — Five seeds are not one rate

### Learning outcomes

After this chapter, you should be able to:

1. List the five printed rates in seed order.
2. Say why the mean is 0.125 when the source threshold is 0.12.
3. Name the divisor 4 in the standard-deviation line.

### 6.1 Each seed builds its own generator and its own 200 draws.

The loop is `for seed in range(5)`. Seed 0 runs first. Seed 4 runs last. Each pass constructs `random.Random(seed)` and counts how often `r.random() < 0.12` across 200 draws. That count divided by 200 is one rate. The five rates print as `0.110 0.130 0.135 0.105 0.145`.

The mean is the sum of those five rates divided by 5, which is `0.125`. The standard deviation takes the squared gaps from that mean, divides by 4, and then takes the square root. The divisor is `len(rates) - 1`, the sample divisor, not 5. The printed sd is `0.017`.

The threshold `0.12` never appears in the output line. A note that replaces the five rates with 0.12 has substituted the generator's cutoff for the realised counts. Those counts differ because each seed starts a different stream.

| Piece | Role in this print |
|---|---|
| Seeds 0 through 4 | Order of the five rates |
| 200 draws | Denominator of each rate |
| Threshold 0.12 | Not printed |
| Divide by 4 | Sample sd, printed 0.017 |

### 6.2 Worked example

| Claim | Decision |
|---|---|
| The five numbers are 0.110, 0.130, 0.135, 0.105, 0.145 | Keep |
| Their mean is the threshold 0.12 | Refuse; the mean prints 0.125 |
| One unlucky seed can sit at 0.105 | Keep; that is seed 3's rate |
| The sd divided by 5 | Refuse; the code divides by 4 |

> **Synthetic case.** These seeds score a toy defence. They are not staff mailboxes.

### Errors and limits

Collapsing five seeds into the source threshold erases the spread the line was printed to show.

### Apply

- **EX052 — Five seeds.** What does the per-seed line report, and why is 0.12 absent from it? *Rubric:* 3 = the five rates, mean 0.125, sample sd 0.017 using divisor 4; 0.12 is only the draw threshold;; 2 = the five rates and the mean;; 1 = the mean only;; 0 = treats 0.12 as a printed rate.

<!-- open-cyber-academy:chapter-navigation:start ch-06 -->
### Continue studying — lesson 06 (chapter 06 of 20)

[← Chapter 05](#ch-05) · [Course chapter index](../SUBJECTS.md) · [Chapter 07 →](#ch-07)

Continue to the next authored lesson.
<!-- open-cyber-academy:chapter-navigation:end -->

## Worked answers

<a id="answer-ex052"></a>
**EX052.** Seeds 0 through 4 each take 200 draws against the threshold 0.12. The printed rates are 0.110, 0.130, 0.135, 0.105 and 0.145. Their mean is 0.125. The standard deviation divides by 4 and prints 0.017. The threshold 0.12 is not a printed rate.
