Chapter 7 — Probability and statistics
Lesson map
Lesson 07 published. Map, example, EX019.
flowchart TD
N0["Learning outcomes"]
N1["7.1 Failure probability"]
N2["Lab — Lab — restore failures"]
N3["7.2 Reading the result"]
N4["7.3 Operational meaning"]
N5["7.4 Independence"]
N6["Measuring p"]
N7["Variance"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> N7
N7 --> EX["Worked example"]
EX --> Q["Exercise EX019"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["7.1 Failure probability"]
N2["Lab — Lab — restore failures"]
N3["7.2 Reading the result"]
N4["7.3 Operational meaning"]
N5["7.4 Independence"]
N6["Measuring p"]
N7["Variance"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> N6 --> N7 --> Q["EX019"]
[Learning outcomes]
|
v
[7.1 Failure probability]
|
v
[Lab — Lab — restore failures]
|
v
[7.2 Reading the result]
|
v
[7.3 Operational meaning]
|
v
[7.4 Independence]
|
v
[Measuring p]
|
v
[Variance]
|
v
[Worked example] --> [Exercise EX019]
Learning outcomes
You will (1) model independent failures with the binomial distribution; (2) interpret probabilities for operations; (3) plan alerting.
7.1 Failure probability
Even a reliable restore job can fail. If each PC's nightly restore fails independently with probability p, the number of failures among n PCs follows a binomial distribution.
The model needs two numbers: how many PCs restore each night and how likely each one is to fail. Mateo takes the first from Fernhill's inventory and assumes the second for planning, to be replaced by measured data from the pilot. The lab then computes the chance of seeing a given number of failures on any night, which is what an alert threshold needs.
Lab — Lab — restore failures
"""Probability that at least k of n public PCs fail a nightly restore, binomial model (stdlib only)."""
from math import comb
n, p = 300, 0.004
for k in (1, 3, 5):
pk = 1 - sum(comb(n, i) * p**i * (1-p)**(n-i) for i in range(k))
print(f"P(at least {k} of {n} fail | p={p}) = {pk:.3f}")
print(f"expected failures per night {n*p:.1f}")
Run with python3 lab_binomial.py. Verified output:
P(at least 1 of 300 fail | p=0.004) = 0.700
P(at least 3 of 300 fail | p=0.004) = 0.120
P(at least 5 of 300 fail | p=0.004) = 0.008
expected failures per night 1.2
7.2 Reading the result
With 300 PCs and p = 0.004, the expected number of failures per night is 1.2. The chance of at least one failure is 0.700, of at least three 0.120, and of at least five 0.008.
Mateo turns those figures into plain statements for Marta. On roughly seven nights in ten, at least one PC will need attention. About one night in eight will have three or more. Five or more should happen less than once in a hundred nights if nothing is wrong. Those statements are easier to act on than the formula, and they come straight from the lab output.
7.3 Operational meaning
Most nights at least one PC will fail to restore, so the design needs an alert and a simple fix. Five or more failures would be very unusual and suggest a shared cause, such as a bad image.
Marta's team agreed that a single failure would be fixed during the morning check by rerunning the restore. A cluster would trigger an investigation before the branches open. Both thresholds are reviewed once real failure rates are known from the pilot. Marta agreed.
7.4 Independence
The binomial model assumes failures are independent. A network outage would break that assumption, causing many failures together.
Mateo lists the shared causes he can think of: a network outage at one branch, a corrupted image file, a power cut during the night or a bad update to the restore software. Any of these would produce many failures at once, far more than the binomial model predicts. That is exactly why the incident alert at five failures is useful: when the count is that high, independence has probably failed, and someone should look for a common cause rather than fixing PCs one by one.
Measuring p
The value p = 0.004 is an assumption for planning. Once the pilot runs, Mateo will measure the actual failure rate from restore logs and update the model. If real failures cluster, for example at one branch, the independence assumption is wrong and alerts should consider branch-level patterns.
This cycle, assume, measure, revise, recurs throughout the course.
Variance
The binomial variance n·p·(1−p) is about 1.2, so nightly counts of zero, one or two failures are all normal.
Using the alert rule
The rule is written into the runbook in chapter 37 and tested in chapter 47's trial, where a deliberately bad image causes many failures at once and triggers the incident alert as predicted. This shows how a probability model becomes an operational tool.
Worked example
Marta asks how to set the alert. Mateo proposes: alert per PC for any failure, and a separate "incident" alert if five or more fail in one night, since that probability is under 1% when the system is healthy.
Synthetic case. Synthetic probability p.
Errors and limits
Real failure probabilities must be measured; p here is an assumption.
Exercises
- EX019 — Expected failures. What is the expected number of failures per night? Rubric: 3 = 1.2; 2 = partial; 1 = vague; 0 = none.
- EX020 — Probabilities. Give P(at least 1), P(at least 3), P(at least 5). Rubric: 3 = 0.700, 0.120, 0.008; 2 = two; 1 = one; 0 = none.
- EX021 — Incident threshold. Why alert as an incident at five failures? Rubric: 3 = under 1% if healthy, suggests shared cause; 2 = partial; 1 = vague; 0 = none.
Synthesis
Probability models turn reliability into sensible alert thresholds.
Continue studying — chapter 07 of 50
← Chapter 06 (draft) · Course chapter index · Chapter 08 (draft) →