Skip to content
Tech Interview Prep
Technical interview guide

Probability Fundamentals

Events, conditional probability, and Bayes' theorem: the building blocks every statistical method assumes.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v7
Editorial status
Reviewed

Scope: Standards and library references current as of 2026-09: NIST/SEMATECH e-Handbook, the 2016 ASA statement on p-values, SciPy, statsmodels, and NumPy.

Interview Q&A

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

25 questions

Q&A-7

How do you distinguish discrete from continuous random variables, and what breaks if you evaluate a PDF like a PMF?

Answer

A discrete random variable takes values in a countable set (finite or countably infinite, like integers), whereas a continuous random variable takes values in an uncountably infinite continuum (such as real intervals).

The defining mathematical mechanism lies in how probabilities are assigned:

  • PMF ($p(x)$): Evaluates directly to a probability: $p(x) = P(X = x)$. The sum over all possible values satisfies $\sum_x p(x) = 1$, and $0 \le p(x) \le 1$.
  • PDF ($f(x)$): Evaluates to probability density, not point probability. For any single exact real value $c$, $P(X = c) = \int_c^c f(x),dx = 0$. Probabilities exist only over non-zero intervals: $P(a \le X \le b) = \int_a^b f(x),dx$, with $\int_{-\infty}^{\infty} f(x),dx = 1$. Consequently, $f(x)$ can exceed 1 and carries dimensional units of $1/\text{unit}(X)$.
Python
import scipy.stats as stats

# Discrete: Poisson rate lambda = 5
# PMF returns actual probability: P(X = 5) ~ 0.175
prob_discrete = stats.poisson.pmf(5, mu=5)

# Continuous: Uniform over [0, 0.5]
# PDF returns density: f(0.2) = 1 / (0.5 - 0) = 2.0 (exceeds 1.0!)
density_continuous = stats.uniform.pdf(0.2, loc=0, scale=0.5)
# Exact point probability is zero:
# stats.uniform.cdf(0.2) - stats.uniform.cdf(0.2) == 0.0

Comparison Table

PropertyDiscrete (PMF $p(x)$)Continuous (PDF $f(x)$)
SupportCountable (e.g., retries, HTTP status codes)Uncountable continuum (e.g., latency, voltage)
Value at a point$P(X = x)$Density: $\lim_{\Delta x \to 0} \frac{P(x \le X \le x + \Delta x)}{\Delta x}$
Range of function$[0, 1]$$[0, \infty)$ (can exceed 1)
$P(X = c)$Can be $> 0$Identically $0$
Total mass / integral$\sum_{x} p(x) = 1$$\int_{-\infty}^{\infty} f(x),dx = 1$

Failure Modes

  1. Treating density as probability in likelihood calculations: In Bayesian inference or maximum likelihood estimation, engineers sometimes reject valid continuous parameter fits because the log-likelihood is positive (meaning $f(x) > 1$). For example, a normal distribution with $\sigma = 0.1$ has peak density $f(\mu) = 1 / (0.1 \sqrt{2\pi}) \approx 3.989$. Truncating density at $1.0$ corrupts model optimization.
  2. Zero-probability paradox in alerting: Querying a telemetry store for latency == 12.450000ms yields zero counts simply due to floating-point dispersion. Latency is continuous; filters must use interval buckets ($[12.4, 12.5)$) or cumulative distribution quantiles ($F(x) = P(X \le x)$).

Curated: · Written: · Reviewed:

Difficulty: Easy
Q&A-1

Explain sample space and events and how it changes a production decision.

Answer

The 90-second answer

A sample space is the set of all outcomes the generating process can produce, written down before you compute anything. An event is a subset of it. The production consequence is blunt: the sample space fixes the denominator of every metric you alert on, and the denominator decides whether the threshold ever fires.

Concrete case. A client retries a failed call up to 3 times. The per-attempt sample space is {success, 500}, and the attempt failure rate is 2%. The per-request sample space is {success, all three attempts failed}. If attempts are independent, P(request fails) = 0.02³ = 8×10⁻⁶, i.e. 8 per million. So the alert on request failure rate belongs at roughly 8 per million, not 2%. Set it at 2% and it never fires: you would need 125,000 requests before expecting a single failure, and the alert is dead code.

Sample space (unit)Event of interestWhat it decides
per attempt500 returnedretry budget, client timeout
per requestall attempts faileduser-facing SLO, alert threshold
per user per dayany request failedsupport load, refund policy

Same service, same 2% attempt failure rate, three different thresholds depending on which space you declared.

The failure mode

Independence is the assumption doing all the work in that 0.02³. A bad deploy fails all three attempts, so the event "all three failed" has probability ≈ 0.02, not 8×10⁻⁶: a factor of 2,500. Detection: put per-attempt and per-request failure rates on the same dashboard. If they converge, retries are buying nothing and the sample space you assumed is wrong. That convergence is the signal, and it shows up within one deploy, not one quarter.

Derive or measure

Two credible ways to get the number, and the sample space tells you which one applies.

Derive it in closed form when the outcome space is enumerable, the process is stationary, and trials are independent: the retry case above. It is exact and free.

Measure it when the outcome space is continuous or heavy-tailed, or the process shifts. p99 latency has no closed form worth trusting: the sample space is all non-negative reals, the tail is what you care about, and the histogram is the answer while a model of it is a guess. Same for cache hit rate: "how many distinct queries will arrive" is not enumerable, so you measure the hit rate directly rather than modelling the space.

Modelling is the wrong tool when the space is not enumerable or the process is non-stationary. Reach for the histogram then; a derivation from a stale sample space is worse than no derivation, because it looks rigorous.

Where this bites in an A/B test

The randomisation unit defines the sample space. Randomise by session but analyse by user, and a user appears in both arms: the independence the t-test assumes is gone, and the effective sample size is users, not sessions. Declare the unit before the test starts, not after the p-value disappoints.

What to say in the room

Name the generating process, write the sample space, then read the denominator off it. If the decision turns on cost rather than semantics (how many retries, what timeout) the space still sets the threshold, but you confirm the independence assumption against production data before you ship it.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-6

What is the difference between mutually exclusive events and independent events, and can two events with non-zero probability be both?

Answer

The 90-second answer

Mutual exclusivity is a claim about the sample space: $A$ and $B$ are disjoint sets, so $A \cap B = \emptyset$ and $P(A \cap B) = 0$. Independence is a claim about the probability measure: $P(A \cap B) = P(A)P(B)$, equivalently $P(A \mid B) = P(A)$ when $P(B) > 0$. Different kinds of statement, which is why they cannot both hold for events of non-zero probability.

Suppose $P(A) > 0$ and $P(B) > 0$. Disjointness forces $P(A \cap B) = 0$. Independence forces $P(A \cap B) = P(A)P(B) > 0$. Contradiction. So no.

The one escape hatch is degenerate: if either event has probability zero, both properties hold vacuously. Take $P(A) = 0$ and $A \cap B = \emptyset$; then $P(A \cap B) = 0 = P(A)P(B)$ for any $B$. That is a boundary case, not a counterexample.

The intuition: disjoint events are maximally negatively dependent. Learning $B$ happened tells you $A$ definitely did not: $P(A \mid B) = 0$, the strongest information possible. Independence means learning $B$ happened tells you nothing. Opposite ends of a spectrum, not two names for one thing.

Quantify it. For disjoint $A, B$, $\mathrm{Cov}(A,B) = P(A \cap B) - P(A)P(B) = -P(A)P(B)$, so

$$\rho = \frac{-P(A)P(B)}{\sqrt{P(A)(1-P(A)),P(B)(1-P(B))}}$$

At $P(A) = P(B) = 0.5$, $\rho = -1$. At $P(A) = P(B) = 0.1$, $\rho = -0.111$. Disjointness is negative dependence, never zero dependence.

PropertyMutually Exclusive (Disjoint)Independent
DefinitionCannot happen together: $A \cap B = \emptyset$One does not inform the other
Joint Probability$P(A \cap B) = 0$$P(A \cap B) = P(A)P(B)$
Conditional Probability$P(A \mid B) = 0$ (for $P(B) > 0$)$P(A \mid B) = P(A)$
Union$P(A \cup B) = P(A) + P(B)$$P(A \cup B) = P(A) + P(B) - P(A)P(B)$
CorrelationNegative, magnitude set by the marginalsZero

Which one to model

Model events as mutually exclusive when the experiment's structure partitions the outcome space: a single node is up or down, a request is served by exactly one replica, a die lands on one face. You can read exclusivity off the definitions, if you can write down one outcome in which both events are true, they are not disjoint.

Model events as independent when they are driven by separate mechanisms with no shared cause: two hosts on different power feeds, two hash functions with different seeds. Independence is an assumption you justify and then test, not a default. The test is empirical: measure the joint frequency and compare it to the product. Observed joint rate above the product means a shared cause; observed joint rate of zero means the events are disjoint, not independent.

Failure mode 1: additive union over independent failures. Ten replicas, each with 10% annual failure probability, failures independent. Applying the disjoint union rule gives $P(\text{at least one fails}) = 10 \times 0.10 = 1.0$. Truth: $1 - 0.9^{10} = 0.651$. Detection: the additive sum exceeds 1, which no probability can. That is the tell. Cost: you declare the fleet guaranteed to fail and either over-provision or discard the model. At two replicas the error is small (0.20 vs 0.19) and easy to miss; it grows with fan-out.

Failure mode 2: multiplying probabilities for outcomes of one variable. A single node's states: $P(\text{up}) = 0.99$, $P(\text{down}) = 0.01$. Applying $P(A \cap B) = P(A)P(B)$ gives 0.0099 for "up and down". Truth is 0. Detection: check whether both events are defined on the same random variable, if they are two values of one variable, they are disjoint by construction and the product is meaningless. Cost: fault trees that double-count, inflating expected incident counts and skewing remediation priority.

The conflation to avoid. "Independent" and "mutually exclusive" both get used to mean "unrelated" in casual speech. In probability they are near-opposites. If you catch yourself writing $P(A \cup B) = P(A) + P(B)$ for events that can co-occur, or $P(A \cap B) = P(A)P(B)$ for events that cannot, you have swapped them.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-8

State the linearity of expectation and explain whether it requires the random variables to be independent?

Answer

Linearity of expectation says $E[X + Y] = E[X] + E[Y]$, and more generally $E[aX + bY + c] = aE[X] + bE[Y] + c$ for constants $a, b, c$. It holds for any random variables with finite expectations. Independence is not required, and neither is uncorrelatedness. Independence only enters when you multiply: $E[XY] = E[X]E[Y]$ requires $X$ and $Y$ to be uncorrelated, which independence implies but which does not follow from linearity.

Why it holds. Expectation is a weighted sum over the joint distribution, and the joint distribution's marginals are the marginals no matter how the variables depend on each other:

$$E[X+Y] = \sum_x \sum_y (x+y),P(X{=}x, Y{=}y) = \sum_x x \sum_y P(X{=}x,Y{=}y) + \sum_y y \sum_x P(X{=}x,Y{=}y) = E[X] + E[Y]$$

The inner sums collapse to the marginal PMFs by definition. Nothing in that step assumed $P(X{=}x, Y{=}y) = P(X{=}x)P(Y{=}y)$.

Where the mistake bites. Linearity does not transfer to variance or to products:

QuantityFormulaIndependence needed?
$E[X+Y]$$E[X] + E[Y]$No: always
$E[XY]$$E[X]E[Y]$ only if uncorrelatedYes (or uncorrelated)
$\mathrm{Var}(X+Y)$$\mathrm{Var}(X) + \mathrm{Var}(Y) + 2,\mathrm{Cov}(X,Y)$Yes, for the covariance term to vanish

Worked example: expected number of occupied bins. Throw $n = 10$ balls independently and uniformly into $m = 10$ bins. Let $I_j = 1$ if bin $j$ is non-empty. Then $E[I_j] = 1 - (1 - 1/m)^n = 1 - 0.9^{10} = 0.6513$. By linearity, $E[\text{occupied}] = \sum_j E[I_j] = 10 \times 0.6513 = 6.513$. The indicators are strongly dependent (if bin 1 is empty, the remaining bins are more likely to be occupied) and the result is still exact. The variance is not $10 , p(1-p) = 2.27$; negative correlation makes it smaller.

python import numpy as np rng = np.random.default_rng(0) n, m, trials = 10, 10, 100_000 balls = rng.integers(0, m, size=(trials, n)) occupied = np.array([len(np.unique(row)) for row in balls]) print(occupied.mean()) # ~6.51 print(m * (1 - (1 - 1/m)**n)) # 6.5132 exact

Counterexample for products. Let $X \sim \mathrm{Bernoulli}(0.5)$ and $Y = X$. Then $E[XY] = E[X] = 0.5$ but $E[X]E[Y] = 0.25$. Same variables, linearity fine, product rule broken.

Failure modes. (1) Claiming independence is needed for linearity: the most common error. (2) Applying linearity to variance, e.g. treating $\mathrm{Var}(X-Y) = \mathrm{Var}(X) + \mathrm{Var}(Y)$ as universal when it needs zero covariance. (3) Applying $E[XY] = E[X]E[Y]$ to dependent quantities, such as estimating expected revenue as $E[\text{price}] \cdot E[\text{units}]$ when a demand curve makes price and units negatively correlated: that product systematically overestimates revenue. Detect it by computing the sample covariance of the two factors before multiplying their means.

Curated: · Written: · Reviewed:

Difficulty: Easy
Q&A-2

How would you reason about conditional probability in a system you own?

Answer

I'd start by naming which quantity the decision actually consumes, because that fixes the conditioning direction. Take a fraud-scoring service I own: the model emits P(fraud | features), but the alert queue consumes P(fraud | alert fired). Precision. Those are different conditionals, and the second is dominated by the base rate, not by the model.

Assume 1 in 1,000 transactions is fraudulent, the model catches 90% of fraud (recall), and flags 5% of legitimate traffic (FPR). Per 100,000 transactions:

fraudlegittotal
alert904,9955,085
no alert1094,90594,915
total10099,900100,000

Precision = 90 / 5,085 ≈ 1.8%. So 98% of alerts are false even though recall is 90%. The model card reports P(alert | fraud) = 0.90; the queue lives on P(fraud | alert) = 0.018. Reading one as the other is the prosecutor's fallacy, and it's the most common way a scoring system ships with the wrong operating point.

Python
def precision(base_rate, recall, fpr):
    tp = recall * base_rate
    fp = fpr * (1 - base_rate)
    return tp / (tp + fp)

precision(0.001, 0.90, 0.05)    # 0.0177
precision(0.001, 0.90, 0.0009)  # 0.5002

To get precision to 50% at the same recall, FPR has to fall from 5% to 0.09%: a 55x cut. That's the trade-off the threshold actually buys, and it's why "improve the model" is usually the wrong lever: at a 0.1% base rate, precision is governed by the false-positive rate on the 99.9% majority.

Failure modes I'd watch:

  • Base-rate neglect in review. If I measure precision only on cases a human already reviewed, I've conditioned on a downstream variable caused by the score itself: a collider. The measured precision is inflated and drifts as the threshold moves. Detect it by holding out a random sample of unreviewed traffic and labeling it.
  • Empty conditioning event. Segmenting by "user has zero prior transactions" is fine until the segment is empty for a new market; P(fraud | segment) is then 0/0. A pipeline that returns 0.0 silently suppresses alerts. Guard with an explicit count check.
  • Correlated features. If the score multiplies per-feature likelihoods assuming conditional independence given the class, device_id and IP from the same device double-count one piece of evidence and inflate the score. Detect by comparing calibration on a held-out set against a model that drops one of the pair.

Alternatives: if the decision is cost-sensitive rather than semantic, don't chase a calibrated probability. Rank and pick the threshold that minimizes expected cost (false-positive review cost vs fraud loss). If the base rate shifts seasonally, re-derive the threshold from the current rate rather than freezing it.

The one thing I'd write into the design doc: which conditional each consumer reads, and the base rate it was computed against.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-3

Walk through bayes' theorem, including where engineers most often get it wrong.

Answer

Bayes' theorem is the rule for reversing a conditional. It falls out of one identity, P(A∩B) is symmetric, so P(A|B)P(B) = P(B|A)P(A), and dividing by P(B) gives:

P(A|B) = P(B|A)·P(A) / P(B), where P(B) = Σᵢ P(B|Aᵢ)·P(Aᵢ)

Read the terms against a detector that fires on some event A:

  • P(A): prior. How often A happens before you look at any evidence.
  • P(B|A): likelihood, a.k.a. sensitivity. How often the detector fires when A is true.
  • P(B|¬A): false-positive rate, 1 − specificity.
  • P(B): evidence. The total firing rate; the normaliser that makes the posterior a probability.
  • P(A|B): posterior. The number you actually want.

The odds form is the one worth carrying, because it shows what evidence does:

posterior odds = likelihood ratio × prior odds, LR = P(B|A) / P(B|¬A)

Evidence multiplies; it never adds. That is why a strong test on a rare event still yields a weak posterior.

Python
# Python 3.12
p_a   = 0.02   # P(disk fills within 24h) on this fleet
p_hit = 0.90   # P(alert | fills)          sensitivity
p_fa  = 0.05   # P(alert | does not fill)  = 1 - specificity

p_alert   = p_hit * p_a + p_fa * (1 - p_a)   # 0.018 + 0.049 = 0.067
posterior = p_hit * p_a / p_alert            # 0.018 / 0.067

lr         = p_hit / p_fa                    # 18.0
prior_odds = p_a / (1 - p_a)                 # 0.02041
post_odds  = lr * prior_odds                 # 0.3673

print(round(posterior, 4), round(post_odds / (1 + post_odds), 4))
# 0.2687 0.2687

Both routes agree: 26.9%. A detector that is 90% sensitive and 95% specific is wrong about three quarters of the time it fires, because the prior is 2%.

Turning that into a decision needs costs, not just a probability. Acting costs C_FP (0.5 engineer-hours to triage); not acting costs C_FN (4 hours to recover a full disk). Act iff posterior > C_FP/(C_FP+C_FN) = 0.5/4.5 = 0.111. At 26.9% you page. Drop fleet prevalence to 0.2% and the same detector gives 0.0018/0.0517 = 3.5%: below threshold, no page. Nothing about the detector changed.

Where engineers get it wrong:

  1. Transposing the conditional. Reporting P(alert|bug) as P(bug|alert). Check which side of the bar the quantity you measured sits on.
  2. Treating accuracy as a property of the test. Accuracy = (TP+TN)/N moves with prevalence; the same detector gives 27% precision at 2% prevalence and 3.5% at 0.2%. Monitor precision on a labelled holdout, not accuracy.
  3. Using the wrong prior. The prior must be P(A) for the population the evidence came from. If the detector only runs on hosts that already crossed a threshold, the prior is prevalence inside that filtered set, not the fleet. Recompute it on the actual query population and track drift (PSI) so you re-derive when it moves.
  4. Multiplying likelihood ratios for correlated evidence. LR₁×LR₂ holds only if the signals are conditionally independent given A. Two alerts from the same failing disk are one observation. Compare the product against the empirically observed joint LR; if it overshoots, the signals share a cause.
  5. Dropping the normaliser in the continuous case. P(B) becomes ∫p(B|θ)p(θ)dθ. Without it you have an unnormalised posterior: fine for ranking, not a probability. Check it integrates to 1.
  6. Double-counting across sequential updates. Posterior becomes the next prior, which is correct only when each likelihood is computed on new evidence. Re-feeding the same evidence squares the LR.

Alternatives, and when each wins:

  • Threshold the likelihood ratio directly (Neyman–Pearson). Same operating point, no prior required, but you cannot state a probability of the event, only a decision.
  • Measure precision empirically on a held-out labelled sample. This beats a modelled prior whenever the sample is representative and large enough; Bayes wins when the event is too rare to have labels for.
  • Conjugate priors (Beta-Binomial for a rate) give closed-form updates and are worth it under continuous updating. A sampled posterior is worth it when the model has structure (per-host rates, hierarchies) that a point estimate hides.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-4

What does the base-rate fallacy in production guarantee, and what does it deliberately leave open?

Answer

The 60-second answer. Take fraud detection: 1M card transactions a day, 0.1% fraudulent. You ship a model with 99% recall and 99% specificity, and it looks excellent on the balanced validation set. In production it fires ~11,000 alerts a day, of which 9% are real fraud. The guarantee is that ceiling: at 0.1% prevalence, precision cannot exceed ~9% unless specificity improves, no matter how good recall is. What is left open is the specificity you actually achieve at your operating threshold, the prevalence you actually face, and whether 9% is good enough: that last one is a cost question, not a statistical one.

Mechanism. Precision is the only one of the four that moves with prevalence. Recall and specificity are conditioned on the true class, so they are invariant to how rare that class is. Bayes makes the arithmetic explicit: posterior odds = likelihood ratio × prior odds. LR+ = sensitivity / (1 − specificity) = 0.99 / 0.01 = 99. Prior odds at 0.1% prevalence are 1:999. Posterior odds = 99 / 999 ≈ 0.099, i.e. a 9% chance the alert is real.

The arithmetic. 1,000,000 transactions, 0.1% fraud = 1,000 frauds and 999,000 legitimate.

  • TP = 0.99 × 1,000 = 990
  • FN = 10
  • FP = 0.01 × 999,000 = 9,990
  • Precision = 990 / 10,980 = 9.0%

Same model, three populations:

PrevalenceFrauds per 1MTPFPPrecision
50%500,000495,0005,00099.0%
1%10,0009,9009,90050.0%
0.1%1,0009909,9909.0%

Guaranteed vs open. Guaranteed: the false-positive count is driven by the size of the negative population, so at fixed specificity precision falls roughly linearly with prevalence. Open: the specificity your model reaches at the threshold you pick. Pushing specificity from 99% to 99.9% cuts false positives to 999 and lifts precision to ~50%, but you have to measure what recall that costs; the production prevalence, which drifts with seasonality, new attack patterns, or a change in an upstream filter; and the threshold itself, which is a cost trade rather than a statistical fact.

Failure mode. Accuracy. A model that predicts "never fraud" scores 99.9% accuracy on this population. The incident shape: a team ships on accuracy, alert volume goes from 200/day to 11,000/day, analysts start bulk-dismissing, and the 10 missed frauds per million become 100 because nobody reads the queue. Detection signal: track precision and the analyst dismissal rate on the alert queue daily; a rising dismissal rate with flat recall means the queue is being ignored, not that fraud stopped. Cost: 9,990 alerts at 2 minutes each is ~333 analyst-hours a day.

What to do. Report precision and recall at production prevalence, not on the balanced set, and recompute when prevalence shifts. Choose the threshold from the cost ratio of a false positive to a false negative, and monitor the score distribution for drift.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-24

What would you ask a candidate who recites the conjunction fallacy in estimation but cannot apply it?

Answer

The probe I'd run is a three-step number elicitation, because the fallacy only surfaces when the candidate has to commit to a figure and then defend the ordering between two of them.

Step 1: get a base number. "We're rewriting the payments service. Give me a probability we ship by March 31." Suppose they say 70%.

Step 2: add a conjunct and re-ask. "Now: probability we ship by March 31 and the reason we hit the date is that the vendor's sandbox stayed stable." A candidate who can apply the fallacy says ≤70%, and usually well under it. A stable sandbox is one of several ways the date holds. A candidate who has only memorised the slogan says "about the same", or worse, 75%, because the story is now concrete and vivid.

Step 3: force the decision. "The date gates a $2M contract with a $50k/week penalty. Do you staff a second team?" The probability is only worth eliciting if it moves a staffing call.

ProbeReciterApplier
P(ship by Mar 31)70%70%
P(ship AND sandbox stable)"75%, it's a realistic scenario""≤70%; the sandbox is one of maybe three ways the date holds, so call it 40%"
Staff a second team?"Depends on risk appetite""At 70%, expected penalty is 0.3 × 13 weeks × $50k ≈ $195k; a second team costs more than that, so no, unless the number drops below ~50%."

Then the reverse probe, which is the one that actually separates the two: "Give me a case where the detailed scenario is more likely than the broad one." For a true superset there isn't one, and a candidate who can apply the fallacy says so and explains that containment is what matters, not specificity. A reciter either invents a case or freezes.

When to use the numeric probe versus something else: it's the right instrument when the decision turns on a threshold, as above. When it doesn't, watch them decompose a live estimate instead: ask them to list the conditions under which the date holds and check the ordering verbally. And measurement beats reasoning when the base rate is unknown but cheap to sample: with 20 past migrations on record, the historical slip rate is a better anchor than anyone's intuition, and a candidate who reaches for that number is showing the model rather than the slogan.

Failure modes to watch for, all of which mean the candidate has the phrase and not the model: anchoring on the first number and never revising it; giving a range that straddles the base number so the ordering is never tested; answering "it depends" without ever committing to a figure.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-5

Describe independence and the evidence you would collect before relying on it.

Answer

Independence is a statement about the joint distribution: events A and B are independent iff P(A∩B) = P(A)·P(B), equivalently P(A|B) = P(A). It is not a property of the components you can read off an architecture diagram: it is a claim about the process generating the failures, and it is usually false for infrastructure that shares anything.

Take three replicas behind a load balancer, each with 99.9% availability. If their failures are independent, joint failure is 0.001³ = 1e-9, about 32 ms of downtime a year. If they sit in one rack on one power feed and deploy together, the joint failure probability is closer to 0.001: 31,536 s, about 8.8 hours. Same components, six orders of magnitude apart. The architecture didn't change; the dependence did.

So before relying on independence, collect evidence about shared fate, not about the components in isolation.

1. Shared-fate inventory. Enumerate everything the events share: rack, PDU, AZ, hypervisor, kernel version, config-management push, DNS resolver, auth service, the deploy that ships them, the client that retries them. Any shared element is a candidate common cause. This is a design review, not a measurement, and it is where most of the answer lives.

2. Co-failure telemetry. From incident and health-check logs, compute the observed P(A∩B) and compare it to P(A)·P(B). A ratio near 1 supports independence; a ratio of 100 says they fail together. Watch the sample size: at 99.9% availability you will not observe a 1e-9 joint event in a year, so you cannot measure independence directly. You measure the shared causes instead.

3. Tail dependence. Independence of means does not imply independence of tails. Correlate the p99 latencies, not the averages; two services can look uncorrelated on the median and lock step under saturation.

4. Controlled fault injection. Kill one replica and watch whether the others' error rates move. Kill the shared dependency (DNS, the config store) and confirm all three fall together. This is the only evidence that tests the mechanism rather than the history.

5. Retry and load amplification. Drive the system to saturation and check whether one node's overload propagates through a shared queue, connection pool, or retry storm. Independence assumed at low load routinely breaks at the knee.

The failure mode this guards against is concrete: assuming independence across correlated failures (replicas in one rack, requests from one user, retries from one client) understates joint failure probability by orders of magnitude, and the happy path hides it because the shared cause only fires under stress.

The decision rule: if the events share a mechanism that can fail, treat them as dependent and design for it. Spread across failure domains, add bulkheads. Only claim independence when a shared-fate inventory comes back empty and co-failure data is consistent with it. Independence is a hypothesis you earn, not a default you assume.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-9

How do variance and standard deviation differ mathematically and operationally, how does variance behave under scaling and addition, and why do we prefer standard deviation for reporting?

Answer

Variance measures the expected squared deviation of a random variable from its mean: $\operatorname{Var}(X) = \mathbb{E}[(X - \mathbb{E}[X])^2] = \mathbb{E}[X^2] - (\mathbb{E}[X])^2$. Standard deviation is its positive square root: $\sigma(X) = \sqrt{\operatorname{Var}(X)}$.

Operational and Physical Interpretation

Variance is expressed in squared units of the underlying metric (e.g., $\text{ms}^2$, $\text{dollars}^2$, or $\text{bytes}^2$). That makes it algebraically convenient, variances add cleanly under independence, but physically uninterpretable when comparing directly against the mean or setting operational bounds. Standard deviation restores the original measurement scale (e.g., $\text{ms}$), allowing direct comparisons such as $\mu \pm k\sigma$ intervals (e.g., Chebyshev's inequality or empirical 3-sigma thresholds in process control).

Algebraic Behavior: Scaling and Shifting

For constants $a$ and $b$:

  • $\operatorname{Var}(aX + b) = a^2 \operatorname{Var}(X)$
  • $\sigma(aX + b) = |a| \sigma(X)$

Additive shifts have zero dispersion effect because they shift the mean by $b$ without changing deviations around the mean. Multiplicative constants scale variance quadratically.

Behavior Under Addition: Independent vs. Dependent

For two variables $X$ and $Y$: $$\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y) + 2\operatorname{Cov}(X, Y)$$ where $\operatorname{Cov}(X, Y) = \mathbb{E}[(X - \mathbb{E}[X])(Y - \mathbb{E}[Y])]$.

  1. Independent (or Uncorrelated) Variables: When $\operatorname{Cov}(X, Y) = 0$, variances are strictly additive: $$\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y)$$ For standard deviation, $\sigma(X + Y) = \sqrt{\sigma_X^2 + \sigma_Y^2} \le \sigma_X + \sigma_Y$. Standard deviations do not sum linearly.
  2. Dependent Variables: When correlated (Pearson's $\rho \in [-1, 1]$): $$\operatorname{Var}(X + Y) = \sigma_X^2 + \sigma_Y^2 + 2\rho\sigma_X\sigma_Y$$
    • If $\rho = 1$ (perfect positive correlation), $\operatorname{Var}(X + Y) = (\sigma_X + \sigma_Y)^2$, so $\sigma(X + Y) = \sigma_X + \sigma_Y$.
    • If $\rho = -1$ (perfect negative correlation / hedging), $\operatorname{Var}(X + Y) = (\sigma_X - \sigma_Y)^2$.

Worked Example: Pipeline Latency

Consider a pipeline with two sequential remote calls, $A$ and $B$, each having $\mu = 50\text{ ms}$ and $\sigma = 10\text{ ms}$ (so $\operatorname{Var} = 100\text{ ms}^2$):

ScenarioCovariance Term$\operatorname{Var}(A + B)$$\sigma(A + B)$
Independent calls ($\rho = 0$)$0$$100 + 100 = 200\text{ ms}^2$$\sqrt{200} \approx 14.14\text{ ms}$
Shared resource congestion ($\rho = 0.8$)$2(0.8)(10)(10) = 160$$100 + 100 + 160 = 360\text{ ms}^2$$\sqrt{360} \approx 18.97\text{ ms}$
Identical bottleneck ($B = A$, $\rho = 1.0$)$2(1.0)(10)(10) = 200$$100 + 100 + 200 = 400\text{ ms}^2$$20.00\text{ ms}$

Common Failure Modes in Practice

  1. Averaging or summing standard deviations directly: Adding $\sigma_A + \sigma_B$ implicitly assumes $\rho = 1$, systematically overestimating combined variance under independent stages.
  2. Ignoring covariance in aggregate budgets: Assuming $\operatorname{Var}(\sum X_i) = \sum \operatorname{Var}(X_i)$ across downstream services that share a common dependency (e.g., database lock contention or shared network transit) leads to drastic underestimation of tail risk.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-15

How would you explain covariance and correlation without using the usual slogan?

Answer

Covariance is the average product of paired deviations from their means: cov(X,Y) = E[(X-μX)(Y-μY)]. It carries the units of X times the units of Y. Correlation is that same average divided by the product of the two standard deviations: ρ = cov(X,Y)/(σX σY). The division is what makes it unitless and bounded in [-1,1]. The bound is not a convention; it is Cauchy-Schwarz: |E[(X-μX)(Y-μY)]| ≤ sqrt(E[(X-μX)^2] E[(Y-μY)^2]) = σX σY. So |ρ| ≤ 1.

What covariance retains that correlation discards is scale and units. If you measure X in meters instead of centimeters, every X deviation multiplies by 100, so covariance multiplies by 100, but σX also multiplies by 100, so ρ is unchanged. Covariance tells you the magnitude of the joint variation in the original units; correlation tells you how well a straight line fits, independent of those units.

Worked example: x = [1,2,3,4,5], y = [2,4,6,8,10]. Means are 3 and 6. Deviations:

| x | y | x-3 | y-6 | product | | 1 | 2 | -2 | -4 | 8 | | 2 | 4 | -1 | -2 | 2 | | 3 | 6 | 0 | 0 | 0 | | 4 | 8 | 1 | 2 | 2 | | 5 | 10 | 2 | 4 | 8 |

Sum of products = 20. Population covariance = 20/5 = 4. σx = sqrt(10/5) = sqrt(2) ≈ 1.414. σy = sqrt(40/5) = sqrt(8) ≈ 2.828. ρ = 4/(1.414*2.828) = 1.0. If x were in centimeters, covariance would be 400, σx would be 141.4, and ρ would still be 1.0.

Code check:

Python
import numpy as np
x = np.array([1., 2., 3., 4., 5.])
y = np.array([2., 4., 6., 8., 10.])
xm = x - x.mean()          # [-2. -1.  0.  1.  2.]
ym = y - y.mean()          # [-4. -2.  0.  2.  4.]
cov = (xm * ym).mean()     # 4.0
corr = cov / (x.std() * y.std())  # 1.0
np.corrcoef(x, y)[0, 1]    # 1.0

Trace: x.mean() = 3.0, y.mean() = 6.0. xm*ym = [8,2,0,2,8], mean = 4.0. x.std() = sqrt(2) ≈ 1.414, y.std() = sqrt(8) ≈ 2.828, product = 4.0, corr = 1.0. np.corrcoef returns 1.0.

Failure modes. Zero correlation does not mean independence. Take x = linspace(-1,1,101), y = x2. mean(x) = 0, mean(x*y) = mean(x3) = 0, so cov = 0 and ρ = 0, yet y is a deterministic function of x. Plot before summarizing. Outliers can dominate both statistics; Anscombe's quartet is the standard demonstration. Pearson's r measures linear association only. Spearman's rank correlation measures monotonic association, is bounded [-1,1], and is robust to outliers and non-linear monotonic relationships. Mutual information captures any dependence, is non-negative, and is zero iff independent (for discrete variables). Sample size matters: for bivariate normal data, Fisher's z transform gives SE ≈ 1/sqrt(n-3). With n=10, SE ≈ 0.38, so r=0.6 is within noise; with n=1000, SE ≈ 0.032. Report n and a confidence interval, not just r.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-16

What failure would you inject to check a team's understanding of correlation and causation?

Answer

The injection. I'd ship a "win" that isn't one: a treatment rolled out to a partner channel instead of randomized, with a dashboard that reports only the aggregate. The team's job is to refuse the number.

Concretely, the readout I'd plant:

SegmentControlTreatment
Mobile2.0% (70% of arm)1.5% (40% of arm)
Desktop12.0% (30% of arm)10.0% (60% of arm)
Overall5.0%6.6%

The aggregate says +1.6pp, ship it. Every segment says the treatment is worse: mobile -0.5pp, desktop -2.0pp. The aggregate only wins because the treatment arm is 60% desktop (12% converting) while control is 70% mobile (2% converting). That's Simpson's paradox, and it's the failure I want to see them catch.

The tell is upstream of the arithmetic: assignment wasn't random. The treatment went to a partner channel that skews desktop, so the comparison is observational, and no amount of segmenting repairs a confounded assignment: it only makes the confounding visible.

What a team that gets it does. First question: "what was randomized?" If the answer is "nothing, we rolled it out to the partner channel," the readout is dead on arrival. Second: a sample-ratio-mismatch check on the assignment variable. A 70/30 versus 40/60 device split at 100k users per arm is a chi-square p far below 0.001, which says the arms aren't comparable before anyone looks at an outcome. Third: they ask whether the segmenting variable is pre- or post-treatment. Device class is pre-treatment, so stratifying on it is legitimate. If someone "controls for" a post-treatment variable (sessions after launch, say) they can open a collider path and manufacture a spurious effect.

Second injection, cheaper to run. A dashboard tile: "Users who enable 2FA churn 40% less." No experiment behind it. The right response is to ask what would be randomized. You can't randomize 2FA adoption practically, so the honest move is a holdback or an encouragement design, not a regression with more controls. A team that adds covariates and calls the result causal has failed the injection.

What failure looks like. They ship on the aggregate, or they "fix" it by adding covariates until the sign flips, or they quote the +1.6pp in the launch review. Any of those means the mental model is a slogan, not a mechanism.

How I'd grade it. Pass = they name the assignment mechanism before the effect size, run the SRM check, and state what they'd randomize next time. Fail = they argue about the size of the effect.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-10

What is the Law of Large Numbers (weak vs. strong), what assumptions are required for it to hold, and how does it differ from the Central Limit Theorem?

Answer

The Law of Large Numbers (LLN) states that the sample average of independent and identically distributed (i.i.d.) random variables converges to their theoretical expected value as sample size grows. The Central Limit Theorem (CLT) describes the shape and dispersion of that sample average around the mean, stating that the standardized sum converges in distribution to a standard normal distribution.

Assumptions Required for LLN

  1. Independent and Identically Distributed (i.i.d.): Observations $X_1, X_2, \dots, X_n$ are drawn from the same underlying distribution without mutual correlation.
  2. Finite First Moment (Mean): $E[|X|] < \infty$. If the distribution lacks a finite mean (e.g., a standard Cauchy distribution), LLN does not apply, and running sample means fluctuate indefinitely without settling on a single value. Note: LLN requires only a finite mean and does not require finite variance, whereas the classical Lindeberg-Lévy CLT requires both a finite mean $\mu$ and a finite, non-zero variance $\sigma^2 < \infty$.

Weak vs. Strong Law of Large Numbers

The difference is the mathematical mode of convergence of $\bar{X}n = \frac{1}{n}\sum{i=1}^n X_i$ to $\mu$:

  • Weak Law (WLLN): Convergence in probability. For any $\epsilon > 0$, $\lim_{n \to \infty} P(|\bar{X}_n - \mu| > \epsilon) = 0$. For any single large sample size $n$, the probability that the sample mean is far from $\mu$ becomes vanishingly small.
  • Strong Law (SLLN): Almost sure convergence. $P(\lim_{n \to \infty} \bar{X}_n = \mu) = 1$. Across an entire infinite realization sequence, the sequence of running averages $\bar{X}_1, \bar{X}_2, \dots$ settles on $\mu$ with probability 1. In practice, WLLN guarantees that taking a single batch of size $n$ works; SLLN guarantees that an ongoing online stream updating its running average will not eventually drift away forever.

LLN vs. Central Limit Theorem

PropertyLaw of Large Numbers (LLN)Central Limit Theorem (CLT)
Question AnsweredWhere does the sample average go?How does the sample average disperse around the mean?
Mode of ConvergenceConvergence in probability (WLLN) / Almost sure (SLLN)Convergence in distribution ($Z_n \xrightarrow{d} \mathcal{N}(0, 1)$)
Rate / Scaling$\bar{X}_n - \mu \to 0$ (error scales at $\mathcal{O}_p(1/\sqrt{n})$)$\sqrt{n}(\bar{X}_n - \mu) / \sigma \xrightarrow{d} \mathcal{N}(0, 1)$
Variance RequirementFinite mean required; finite variance not requiredRequires finite, non-zero variance $\sigma^2 < \infty$
Python
import numpy as np

rng = np.random.default_rng(seed=42)
n = 200_000

# Standard Normal: finite mean (0), finite variance (1) -> Both LLN and CLT hold
normal_samples = rng.normal(loc=0.0, scale=1.0, size=n)
print(f"Normal sample mean: {normal_samples.mean():.4f}")  # converges to 0.0

# Standard Cauchy: undefined mean, infinite variance -> LLN and CLT both FAIL
cauchy_samples = rng.standard_cauchy(size=n)
print(f"Cauchy sample mean: {cauchy_samples.mean():.4f}")  # unstable, e.g. -1.412 or 34.201

# Lomax / Pareto II from numpy.random.pareto(a):
# numpy draws Y with pdf f(y) = a / (1 + y)**(a + 1) for y >= 0.
# For a = 1.5, E[Y] = 1 / (a - 1) = 2.0. Variance is infinite since a <= 2.
# LLN holds (converges to 2.0), but standard CLT fails.
pareto_ii_samples = rng.pareto(a=1.5, size=n)
print(f"Pareto II sample mean: {pareto_ii_samples.mean():.4f}")  # converges to 2.000

Common Failure Modes in Production

  1. Heavy-Tailed Workloads (Infinite Variance): In network latencies, file transfers, or query execution durations, distributions often follow power laws with tail indices $\alpha \le 2$. While the sample mean will eventually satisfy LLN if $\alpha > 1$, convergence is slow, and constructing Wald-style normal confidence intervals fails because CLT conditions are violated.
  2. Correlation / Autocorrelation: Time-series telemetry, session-level user behavior, and clustered A/B test routing violate the independent observations assumption. When positive autocorrelation exists, the effective sample size is much smaller than $n$, leading to underestimating variance and declaring false convergence.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-11

What would you measure before treating the central limit theorem as settled?

Answer

Before I'd call the CLT settled for a given dataset, I'd measure four things on the data in front of me, not on the theorem: the sample skewness and excess kurtosis, the third-absolute-moment ratio ρ/σ³ that sets the Berry–Esseen rate, the tail index (to confirm the variance is even finite), and the actual sampling distribution of the mean by resampling, then compare the coverage of the normal interval against a bootstrap interval. Assumptions: observations iid, finite variance. If either fails, no amount of n fixes it.

Why those four. The CLT's error is not O(1/√n) with a universal constant; the leading term is the skewness. The Edgeworth expansion gives

F_n(x) = Φ(x) + (γ₁/(6√n))(1 − x²)φ(x) + O(1/n),

so the deviation from normality at any x scales with γ₁/√n. Berry–Esseen states the same as a bound: sup_x |F_n(x) − Φ(x)| ≤ C·(ρ/σ³)·1/√n, with the sharpest known constant C ≤ 0.4748 (Shevtsova, 2011). ρ = E|X−μ|³ is dominated by the tail, which is why a distribution with modest skewness but fat tails still converges slowly.

Two consequences worth stating. First, the O(γ₁/√n) term is even in x, it shifts both tails the same way, so a symmetric two-sided interval is second-order accurate; it's the O(1/n) kurtosis term that breaks two-sided coverage, while one-sided intervals feel the skewness at first order. Second, if the tail index α ≤ 2 (Pareto, α-stable), the variance is infinite, ρ/σ³ is undefined, and the mean converges to a stable law, not a normal one. That is not slow convergence; it is the wrong limit.

The measurement, in code:

Python
import numpy as np
rng = np.random.default_rng(0)

def clt_diagnostics(x, n, B=10_000):
    x = np.asarray(x, float)
    m, s = x.mean(), x.std(ddof=1)
    g1   = ((x - m)**3).mean() / s**3            # sample skewness
    kurt = ((x - m)**4).mean() / s**4 - 3        # excess kurtosis
    rho  = (np.abs(x - m)**3).mean() / s**3      # Berry-Esseen input
    idx   = rng.integers(0, len(x), size=(B, n))
    means = x[idx].mean(axis=1)                  # sampling dist of the mean
    z     = (means - m) / (s / np.sqrt(n))
    return g1, kurt, rho, np.mean(np.abs(z) <= 1.96)   # nominal 95%

The last value decides it: if the normal interval's empirical coverage at your n is 0.95, the CLT is settled for that decision; if it's 0.90, it isn't, and you use the bootstrap percentile interval instead.

Arithmetic for the skewness term. Exponential data has γ₁ = 2. At n = 30 the Edgeworth correction at x = 1.96 is (2/(6√30))(1 − 1.96²)φ(1.96) = 0.0609 × (−2.842) × 0.0584 ≈ −0.0101: about one percentage point of CDF mass, which is why n = 30 is fine for a symmetric interval but marginal for a one-sided one. Log-normal with σ = 3 has skewness (e⁹+2)√(e⁹−1) ≈ 7.3×10⁵. The leading correction is O(γ₁/√n), so as an order-of-magnitude estimate, bringing it under a percentage point needs n around 4×10¹²: no practical sample size rescues it, and the bootstrap is the only honest interval.

Failure modes to name: applying the CLT to the data rather than to the mean; heavy tails where ρ is enormous or infinite; dependence, where autocorrelated series break the √n scaling; and using the normal interval when the coverage check says otherwise. The resampling check above detects all of them, and it is the measurement the question is asking for.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-12

How does sampling distributions change if the workload grows by two orders of magnitude?

Answer

Workload doesn't enter the sampling distribution directly: sample size and the stability of the population do. Growing traffic 100x changes both, and they push in opposite directions.

If you scale the sample with the traffic (n: 400 → 40,000), the standard error of the mean falls by √100 = 10x. If you instead keep n fixed per window and just collect 100x more windows, each window's sampling distribution is unchanged; only the pooled estimate tightens, and only if the population is stationary across those windows. At 100x traffic it usually isn't.

The arithmetic

Latency, σ = 20 ms.

regimenσSE of mean
baseline40020 ms1.0 ms
100x, sample scaled, σ constant40,00020 ms0.1 ms
100x, sample scaled, σ grows to 60 ms40,00060 ms0.3 ms
100x, n fixed, 100 windows pooled400 × 10020 ms0.1 ms nominal

The third row is the one people miss: at high utilization the latency distribution gets heavier-tailed, σ grows, and the 10x gain shrinks to about 3x. The fourth row is nominal only: it assumes the 100 windows are draws from one population.

Why σ grows

Queueing. Below roughly 70% utilization, latency is close to the service-time distribution. As you approach saturation, wait time dominates and the tail stretches: M/M/1 wait time scales with ρ/(1−ρ), so the variance grows faster than the mean. The sampling distribution of the mean becomes right-skewed, and the normal-approximation CI undercovers.

Failure modes

  • Non-stationarity. At 100x you span more diurnal cycles and more regime changes. Detect it by comparing the between-window variance of the per-window means to the within-window SE: if between ≫ within, you have drift, not sampling noise, and pooling is invalid.
  • Heavy tails. Compare a bootstrap CI to the normal CI; if they diverge, the CLT hasn't kicked in at your n. Report the median or p99 instead of the mean.
  • Bias dominating variance. At 100x you can afford to sample everything, so sampling error goes to zero and instrumentation error (clock skew, aggregation-window misalignment, dropped metrics under load) becomes the whole error budget. Detect it by reconciling sampled aggregates against full-population ones.

What to do

Decide first whether the process is stationary over your measurement window. If yes, scale n with traffic and take the √n win. If no, don't pool: report per-window distributions and treat the between-window spread as the uncertainty. If the decision turns on the tail (SLOs usually do), stop estimating the mean and estimate the quantile directly with a bootstrap.

Python
import numpy as np
rng = np.random.default_rng(0)
# heavy-tailed latency, as seen near saturation
x = rng.pareto(1.5, 40_000) * 20
mean_se = x.std(ddof=1) / np.sqrt(len(x))
boot = np.percentile([rng.choice(x, len(x)).mean() for _ in range(2000)], [2.5, 97.5])
# if the bootstrap interval is much wider than ±1.96*mean_se, the CLT is not yet valid here

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-14

When would you refuse a design because of the interval width and sample size?

Answer

I refuse when the interval the experiment can actually produce is wider than the difference the decision turns on. That is the whole test: if the confidence interval at the feasible sample size spans both "ship" and "don't ship," the experiment cannot answer the question, and running it just burns traffic.

The half-width is z·σ/√n. At 95%, z = 1.96, so with σ = 20 the half-width is 39.2/√n:

Target half-widthRequired n
4.096
2.0384
1.01,537
0.56,147

That table is the refusal rule. Three triggers make me say no:

  1. Required n exceeds what the decision window can supply. If I need 6,000 sessions and the system serves 400 a week with a two-week decision window, I refuse. The interval will be roughly 2.8 wide instead of 1.0, and the decision will not be made on it.
  2. The minimum detectable effect at feasible n is larger than the effect anyone would act on. If the narrowest interval I can buy resolves a 3% lift and the business only cares about ≥1%, the experiment is underpowered for the actual question. Refuse.
  3. The width is dominated by variance I cannot reduce and a metric I cannot change. If the metric is a heavy-tailed p99 and the variance is intrinsic, no amount of cleverness fixes it inside the budget.

When I hit a trigger, the alternatives are concrete and I pick by cost:

  • Widen the interval: accept less precision. Only valid if the decision is robust across the wider range; if both ends of the wider interval still lead to the same action, the precision was never needed.
  • Reduce variance: paired or blocked designs, stratification, or variance reduction on pre-period covariates. This buys precision without more traffic, and it is usually the cheapest lever.
  • Change the metric: swap a noisy proxy for a lower-variance one that still tracks the decision.
  • Run a sequential design: group-sequential or always-valid intervals let you stop early when the effect is large, at the cost of a slightly wider interval at any fixed n.

Two failure modes I watch for. First, assuming a linear return on data: people budget for 2× precision when it costs 4× the sample, so the plan is underpowered from the start. Detect it by computing required n from the target width before launch; the cost of catching it late is the full experiment duration wasted and the decision slipping a quarter. Second, planning σ from a small pilot that underestimates the true variance: the observed interval comes in wider than promised. Detect it by monitoring observed σ mid-flight against the planning σ; if it is 1.5×, required n is 2.25×.

So I refuse, not because the design is wrong, but because the decision does not fit the budget, and I name which lever I would pull: more data, less variance, or a coarser question.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-13

A vendor promises confidence intervals is handled for you. What do you still own?

Answer

What you own

The vendor owns the arithmetic: the point estimate, the standard error, the interval bounds. You own every assumption that arithmetic is conditional on, and the decision it feeds: the estimand, the randomization unit and independence, the data pipeline, the model the interval assumes, the interpretation, and the verification that coverage actually holds on your traffic.

Vendor ownsYou own
point estimate, standard error, boundswhat parameter the interval is even for
the formula (Wald, Wilson, bootstrap)whether its assumptions hold on your data
the dashboard renderingthe randomization unit and independence
dedup, bot filtering, late-arriving events
the decision threshold and the cost of a wrong call
a coverage check on your own data-generating process

Why the assumption is the whole thing

A confidence interval is estimate ± z·SE. The vendor computes SE from a variance model. If your data violates that model, the interval is confidently wrong: the number is precise and the coverage is not 95%.

Artefact 1: the degenerate interval.

Python
import math
n, phat, z = 100, 0.0, 1.96
wald = (phat - z*math.sqrt(phat*(1-phat)/n),
        phat + z*math.sqrt(phat*(1-phat)/n))
denom = 1 + z*z/n
center = (phat + z*z/(2*n)) / denom
half = z*math.sqrt(phat*(1-phat)/n + z*z/(4*n*n)) / denom
print(wald, (center - half, center + half))

Trace: phat=0 makes the Wald standard error √(0·1/100)=0, so wald=(0.0, 0.0). A zero-width interval asserting the rate is exactly zero. Wilson: denom=1+3.8416/100=1.038416, center=0.019208/1.038416=0.018497, half=1.96·√(3.8416/40000)/1.038416=1.96·0.0098/1.038416=0.018497, so it prints (0.0, 0.036995). The normal-approximation form is the common default; you own noticing that "0 conversions in 100" is not evidence the rate is 0.

Artefact 2: clustering. If each user contributes m sessions and within-user correlation is ρ, the variance is inflated by the design effect 1+(m−1)ρ. With m=10 and ρ=0.05 that is 1.45, so the interval is √1.45 ≈ 1.20: about 20% too narrow. The vendor counted sessions; you own knowing the randomization unit was users.

Failure modes and how you catch them

  • Degenerate or absurdly narrow intervals at low counts. Detect: alert when width is 0 or p̂ ∈ {0,1}; switch to Wilson or an exact interval.
  • Clustered or panel data. Detect: compare the vendor interval to a cluster bootstrap; a width ratio near √design effect confirms it.
  • Peeking. Five independent looks at α=0.05 give family-wise error 1−0.95⁵ ≈ 23%. Detect: use an always-valid or alpha-spending interval and compare.
  • Drift and non-stationarity. Detect: split-half coverage check. Build intervals on the first half, measure coverage on the second.
  • Pipeline defects: late-arriving events, duplicate users, bot traffic. The interval is conditional on the rows you fed it.

The verification you actually own

Run a coverage simulation on your own data-generating process, not the vendor's. Draw from your metric's real distribution (clustered, heavy-tailed, whatever it is) build the interval 10,000 times, count how often it contains the truth. If it returns 0.91, you own the gap, and no vendor SLA closes it.

Then the decision: the interval is an input. You own the threshold, the cost of a wrong call, and the guardrails.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-22

What is the smallest experiment that would change your mind about simulation as a check?

Answer

The smallest experiment: a known-answer test.

Pick a quantity you can compute in closed form, run your simulator on it, and check whether the exact value lands inside the simulation's own confidence interval. That is the whole experiment: one function, one seed, a few seconds of compute. If the exact value is inside the interval, simulation is a usable check for that class of problem. If it is outside, the harness is wrong, and no number of extra replications will fix it.

Why this is the right size. Monte Carlo error shrinks as 1/√n, so the confidence interval is the yardstick: a correct estimator misses the true value about 5% of the time at 95% confidence. A biased estimator (off-by-one in the trial loop, wrong distribution, wrong normalization) misses far more often. The known-answer test calibrates the estimator and the error bar at the same time, which is exactly what you need before trusting either.

The experiment.

Python
import numpy as np

rng = np.random.default_rng(20260907)
n = 200_000
# exact: P(>=7 heads in 10 fair flips) = (120+45+10+1)/1024 = 176/1024
flips = rng.random((n, 10)) < 0.5
hits = (flips.sum(axis=1) >= 7).mean()
se = np.sqrt(hits * (1 - hits) / n)
print(hits, se, hits - 1.96 * se, hits + 1.96 * se)

Trace: rng.random((n, 10)) draws 2,000,000 uniforms; < 0.5 turns each into a fair coin; sum(axis=1) counts heads per trial; >= 7 marks the trials that qualify; .mean() is p̂. With p ≈ 0.171875, the standard error √(p(1−p)/n) is about 0.00084, so the 95% interval is roughly 0.171875 ± 0.00165. The exact value 0.171875 must sit inside it.

Decision rule. One miss is a 1-in-20 event; rerun with two more seeds. Two or more misses out of three (probability ≈ 0.007 if the harness is correct) means the harness is broken: stop and fix it before using simulation for anything.

What it does not prove. The test validates the estimator and the error bar, not the model. If your simulated distribution is wrong, the known-answer test passes and the check still lies. So simulation can refute a derivation (if the analytic value falls outside the interval, one of the two is wrong) but it cannot confirm the model you fed it.

Failure modes it catches and misses. It catches a wrong SE formula only if the test shares the correlation structure that broke it; independent-sample SEs on autocorrelated output will pass a naive test and fail in production. It catches rare-event blindness: if p̂ = 0 after 200k replications, the interval is degenerate and the estimator cannot resolve the event at all. It does not catch a wrong model, and it does not catch variance reduction (antithetic, common random numbers) that changes the SE formula without changing the point estimate.

Alternatives. Exact derivation when the form is tractable; exhaustive enumeration when the state space is small; a second independent implementation when you need a cross-check. Simulation is the cheapest option when the state space is too large to enumerate and the analytic form is intractable, and the known-answer test is what tells you it is trustworthy enough to use.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-23

How does the Monte Carlo error interact with rollback, and where do people ignore that?

Answer

Monte Carlo error and rollback interact in two places, and both are usually missed. First, the rollback gate is a threshold test on a noisy estimate, so the simulation's standard error is the false-rollback rate. Second, rollback truncates the observation window: the estimate you acted on is selected on having crossed the threshold, so it is biased upward, and the data that would have told you whether the rollback was justified never gets collected.

The gate is a noisy threshold test

If the gate is "roll back when the simulated probability of a slow request exceeds 1%", the estimator is a binomial proportion over N replications, with standard error sqrt(p(1-p)/N). The gate fires on noise whenever the true value sits within a couple of SE of the threshold.

Python
import math
p, N = 0.0095, 20_000          # true rate 0.95%, 20k replications
se = math.sqrt(p * (1 - p) / N)  # 6.86e-4  -> 0.069 percentage points
threshold = 0.0100
z = (threshold - p) / se         # 0.73
# P(estimate crosses 1.0% | truth is 0.95%) = P(Z > 0.73) ~= 0.23

So roughly 23% of canaries that are identical to baseline roll back. That is the number to put in front of the team, not "the simulation is noisy".

Peeking multiplies it

If the gate is evaluated every minute for 30 minutes and rolls back on the first crossing, the single-look 23% is not the rate you get. Treating the looks as independent gives 1 - 0.77**30 ~= 0.9997; overlapping windows make the true figure lower, but it stays far above 23%. A gate that peeks is a sequential test whether or not anyone called it one.

Rollback selects the estimate

At the moment of rollback the estimate is conditioned on having crossed. With the numbers above, the expected observed value given a crossing is 0.95% + 0.069pp * phi(0.73)/(1 - Phi(0.73)) = 0.95% + 0.090pp = 1.04%. The incident review reads 1.04%, concludes the canary was bad, and the true effect was 0.95%: 0.09 pp of that gap is pure selection, not regression.

Where people ignore it

  • Threshold set on the point estimate. No noise budget, so the gate sits inside the simulation's own SE. Detect it with an A/A canary: if identical-to-baseline rollbacks run at 20%+, the gate is noise-driven.
  • Peeking treated as a single test. The nominal threshold is not the operating threshold.
  • n and SE not logged with each gate evaluation. Post-hoc you cannot separate signal from selection, so the incident review misattributes.
  • A Monte Carlo gate inside a cost or risk model. The model's SE is never propagated into the threshold, so the gate inherits noise nobody budgeted.
  • Rollback latency shorter than the metric window. You are reacting to noise you cannot outrun.

Trade-offs

  • Widen the threshold to mu + 3*se. False rollbacks drop to ~0.1%, but you now miss true regressions smaller than ~0.2 pp.
  • Raise N. SE falls as 1/sqrt(N); 4x replications halves it, at 4x simulation compute.
  • Sequential test (alpha spending, SPRT). Controls the peeking inflation properly, at the cost of implementation complexity and some sensitivity.
  • Require two consecutive crossings. Cheap hysteresis, one window of added detection delay.

None of this applies when the failure is safety-critical: data corruption or a security regression rolls back on any signal, because the cost asymmetry dominates the noise budget.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-21

How would you brief product on why the birthday problem and collisions delays a ship date?

Answer

I'd open the briefing with the sentence that decides the date: the launch plan assumes 5 million IDs in year one, and the ID scheme we picked collides with near-certainty at that volume. The date moves by however long it takes to change the ID format, not by however long it takes to fix a bug: there is no bug, the scheme is working exactly as designed.

Two assumptions I'd state out loud, because the whole argument rests on them. First, IDs are generated without coordination (random, or derived from a hash) so two writers can independently produce the same value. Second, the volume projection is the one in the launch plan, not a guess of mine.

The number product needs is this: collisions scale with the square of volume, not with volume. The probability of at least one duplicate among n IDs drawn from a space of size N is roughly 1 − e^(−n²/2N), so you hit 50% at about 1.18·√N.

Space50% collision atProbability at 5M IDs
2^32~77,000~1 (certain)
2^64~5.1 × 10^97 × 10^−7
2^122 (UUIDv4 random bits)~2.7 × 10^18~0

At 5M IDs in a 32-bit space the exponent is 5M² / (2 × 4.29 × 10^9) ≈ 2,900, so a duplicate is not a risk, it is a certainty. In a 64-bit space the same volume gives 2.5 × 10^13 / 3.69 × 10^19 ≈ 7 × 10^−7. That gap is the entire delay: we are not choosing between shipping and not shipping, we are choosing which of three changes to make before we take production traffic.

OptionWhat changesCostWhat it risks
Widen to 128-bit randomcolumn type, API contract, client SDKsmigration of existing rows plus a client releasebreaks anything parsing or storing the ID as a fixed-width value
Coordinated sequence (timestamp + worker ID, Snowflake-style)new generator servicea day or two, plus clock-skew handlingworker-ID collisions if config drifts across deploys
Keep the format, dedupe on writeunique index plus retrywrite-path latency and index sizeduplicates already written before the index existed

The deciding questions are concrete, and I'd put them to product rather than answer them myself. Is the ID customer-visible: in URLs, exports, or a partner contract? If yes, widening is a breaking change and the sequence is cheaper. Does the write path already funnel through one primary database? If yes, a sequence costs a day and no format change at all. And what does a duplicate actually cost: a dropped analytics event, or a double charge? That last one sets how much delay is worth buying.

The failure mode is that this never shows up in testing. Staging generates thousands of IDs, not millions, so the collision rate there is indistinguishable from zero; the first duplicate appears in production, as a unique-constraint violation spike or a merge conflict on a record that should have been one row. I'd instrument the collision rate and the unique-violation rate before launch and alert on both, so the number in the briefing is the number we can watch move.

What would change my recommendation: if the ID is internal-only and writes already go through a single primary, the sequence is a day of work and the date barely moves. If the ID is in a public contract, the honest briefing is that the format change is the critical path and the date should be set from the migration, not from the feature.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-20

What trade-off does percentiles do not average force that a junior answer usually skips?

Answer

The trade-off is that a correct cross-shard percentile costs you the summary. To merge percentiles you have to keep the distribution, a histogram or a sketch, and that costs memory per series, cardinality in your metrics store, and bytes on every scrape. A junior answer says "don't average percentiles" and stops; the trade-off is what you pay to avoid it, and what you lose if you don't.

Mechanism: a percentile is an order statistic. p95(A ∪ B) is a function of the full multiset A ∪ B, not of p95(A) and p95(B). Averaging two order statistics gives you a weighted mean of two points, which is not an order statistic of the union.

Worked example. Two shards, unequal traffic.

ShardRequests≤10 ms100 ms1000 msp95 (nearest-rank)
A100095050010 ms
B109011000 ms

Average of per-shard p95 = (10 + 1000)/2 = 505 ms. Merged: 1010 requests, sorted positions 1–959 are 10 ms, 960–1009 are 100 ms, 1010 is 1000 ms. p95 = ceil(0.95 × 1010) = 960th value = 100 ms. The average is 5× the truth, and the truth is not either shard's number.

To get 100 ms you need the merged histogram: 959 in [10,10], 50 in [100,100], 1 in [1000,1000]. That is the artefact you must ship.

Now the trade-off, option by option:

  • Raw values. Exact, any percentile, any window. Cost: memory and network proportional to request count. Not viable at scrape scale.
  • Pre-bucketed histogram (classic Prometheus). Mergeable by summing bucket counts. Cost: you commit to bucket boundaries before you see the data, so resolution is fixed; each bucket is a separate time series, so a histogram with 10 buckets multiplies cardinality by 10 per label set. If p95 lands on a boundary, the reported value is the bucket's upper bound and the percentile looks like a step function.
  • Sketch (t-digest, DDSketch). Bounded memory, mergeable. DDSketch gives a relative-error guarantee; t-digest does not, so its accuracy is empirical. Cost: approximation you must state, plus a merge step.
  • Precompute p95 at the edge and average. Cost: nothing, and the number is meaningless across shards of unequal size.

The failure mode is quiet. Averaging p95 across shards looks fine when shards are equal-sized and identically distributed: the average happens to land near the truth. It breaks when traffic is skewed, which is the normal case: one hot shard, one cold shard. Detect it by comparing the averaged number against the merged histogram on the same window; they diverge exactly when the shards are unequal. Second failure: bucket-boundary pinning, visible as a percentile that never moves between two values. Third: cardinality blowup, visible in prometheus_tsdb_head_series after you add histograms per route.

So the trade-off a junior skips: correctness of the merged percentile is bought with per-series memory, cardinality, and a commitment to resolution you make before you know the distribution. If you won't pay it, the honest answer is that your percentile is valid within one shard and any cross-shard figure is a fiction.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-19

How would you review a pull request whose risk is expectation versus percentiles?

Answer

The first question is what decision the metric drives, not what the diff computes. Expectation is linear: E[X+Y] = E[X]+E[Y], so means and sums compose across instances, shards and time by addition. Quantiles are not linear: p99(A∪B) is not any function of p99(A) and p99(B). That asymmetry is the whole risk. If the metric gates a user-facing latency SLO, a mean hides the tail. If it gates a cost, bandwidth or queue-depth budget, a percentile hides the total. So I read the diff for the aggregation function and the alert threshold, then say which of the two the decision actually needs.

Mean where the tail is the SLO. 100 requests, 95 at 20 ms, 5 at 2000 ms:

Python
latencies = [20] * 95 + [2000] * 5
mean = sum(latencies) / len(latencies)   # 119.0
s = sorted(latencies)
p50, p95, p99 = s[49], s[94], s[98]      # 20, 20, 2000

Mean 119 ms, p95 20 ms, p99 2000 ms. An alert on mean > 100 ms fires and still never says that 1% of users wait two seconds. The mean lands between p95 and p99, so it describes neither the typical request nor the bad one. Review comment: "SLO is p99 < 500 ms; this alerts on the mean. On the attached trace the mean is 119 ms while p99 is 2000 ms, so the tail is invisible. Switch to p99 off the existing histogram."

Percentile where the total is the budget. 1000 requests, 999 at 1 KiB and 1 at 1 MiB. p99 = 1 KiB, but the total is 999 KiB + 1024 KiB = 2023 KiB ≈ 2.0 MiB, and the mean is 2.02 KiB: above p99. Here the mean is the honest number and the percentile undercounts the total by 2×. Comment: "This feeds a capacity number; use sum or mean × count. p99 of individual sizes will undercount the total."

When percentiles are right, check how they're merged. Averaging per-instance p99s is invalid: it's an average of order statistics, not a quantile. The diff has to merge the underlying distributions:

PROMQL
# wrong: averaging per-instance quantiles
avg(http_request_duration_seconds:p99)

# right: one quantile over merged buckets
histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))

Two failure modes to check while you're there. Bucket resolution: histogram_quantile interpolates linearly inside a bucket, and a quantile landing in the +Inf bucket is reported as the highest finite bound. A 30 s tail reads as 10 s if the buckets stop at 10 s. Sample starvation: a p99 needs at least 100 samples in the window to be defined at all, and a few hundred before it stops flapping, so at 100 requests/min either widen the window or alert on a lower quantile.

What I'd actually write. Name the line, name the decision, offer the fix: "avg_latency = sum(latency)/count, alert at > 100 ms. Trace shows mean 119 ms, p99 2000 ms. Tail users are invisible. Suggest p99 > 500 ms off the histogram, plus a panel with mean and p99 side by side so the skew is visible." If the metric is for capacity, the mean is right and I'd say so: the review is about which decision the number informs, not about percentiles being better.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-17

How should on-call treat an alert that names simpson's paradox as the cause?

Answer

First 90 seconds. The alert fired on a metric condition: say aggregate checkout error rate above 2% for 10 minutes. "Simpson's paradox" is an annotation someone attached to it, not a cause. Treat it as a hypothesis to confirm or kill, and answer one question: is any user worse off than before the window?

Pull the per-segment breakdown for the same window and compare each segment against its own SLO. If every segment is flat and the aggregate moved only because the traffic mix moved, no user is worse off. That is an alerting defect, not an incident: downgrade it, note the annotation, and fix the alert to evaluate per segment or to weight against a fixed baseline mix.

Worked example (hypothetical numbers):

SegmentBeforeAfter
us-east1.0% (100/10,000)1.0% (50/5,000)
eu-west3.0% (300/10,000)3.0% (1,350/45,000)
Combined2.0% (400/20,000)2.8% (1,400/50,000)

Each segment is unchanged; the aggregate rose from 2.0% to 2.8% because eu-west's share went from 50% to 90%. The arithmetic: 0.01 × 5,000 + 0.03 × 45,000 = 1,400 errors over 50,000 requests.

Then check why the weights moved. The mix shift is often the real signal. eu-west going from 50% to 90% of traffic is not normal: a load-balancer failover, a retry storm, a DNS change, or a bad canary shifting traffic will all do it. If the shift has no benign explanation, you have an incident whose symptom is the mix, not the error rate.

Failure modes and how to catch them.

  • Dismissing a real regression because the label sounds authoritative. Detection: check every segment against its own SLO, not just the aggregate. A segment that breached while the aggregate looked fine is the mirror image and equally dangerous.
  • The mix shift being the fault. Detection: alert on segment traffic share changing more than a set percentage in a window, or on the load balancer's own health checks.
  • Alert fatigue from aggregate-only thresholds. Detection: count how often this alert fires with no segment breach. If that is most of the time, the alert is wrong.

What to do. If segments are clean and the mix shift is explained, downgrade and fix the alert. If segments are clean but the mix shift is unexplained, keep it open and page the team that owns traffic routing. If a segment breached, it is a normal incident and the aggregate is irrelevant.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-18

What belongs in a runbook section on survivorship and selection bias, and what does not?

Answer

What a strong candidate says first (60–120s)

A runbook section on survivorship bias is not an explanation of survivorship bias. It is the two things an on-call engineer needs at 3am: the query that tells them a metric is survivor-conditioned, and the action to take when it fires. The definition, the proof, and "be careful about sampling" belong in the metric's design doc, not the runbook.

State the assumption up front: this section is for one named metric, say avg_tenure on the growth dashboard, not for bias in general.

What belongs

  1. The detection query, with real table and column names, and the threshold that fires it.
SQL
-- Survivorship check for avg_tenure (PostgreSQL 14+)
SELECT
  avg(now() - signup_at) FILTER (WHERE status = 'active') AS survivor_avg,
  avg(now() - signup_at)                                  AS all_users_avg
FROM users;

The FILTER clause restricts the first aggregate to active rows; the second aggregates every row. Alert when survivor_avg / all_users_avg > 1.5 for two consecutive hourly runs. Set that ratio from your own backfill, not from this page.

  1. The direction of the bias, so the reader knows which way to correct. The survivor average is always ≥ the true average here, because the filter keeps only users who have not churned.

  2. The excluded population and how to reconstruct it: churned users sit in the same table with status = 'churned' and a churned_at timestamp. The all_users_avg column is that reconstruction.

  3. A worked example with numbers, so the reader can sanity-check the alert.

Hypothetical: 1,000 signups over 24 months. 400 still active, average tenure 14 months. 600 churned, average tenure at churn 3 months. True average = (400×14 + 600×3)/1000 = 7.4 months. The active-only query returns 14 months: 1.9× the truth, and it climbs every month retention slips, because the denominator only keeps survivors.

  1. Escalation: who owns the metric, and the two fixes. Switch the dashboard to a cohort metric (retention by signup week), or keep the point-in-time average but relabel it "active-user tenure" and stop comparing it to churn-inclusive targets.

What does not belong

  • The definition of survivorship bias, or why it is a form of selection bias. That is a design-doc paragraph.
  • Generic cautions ("always check your sample"). They do not change what the on-call does.
  • A query without table and column names, or a threshold without the backfill that set it.
  • Proofs. The runbook states the direction of the bias; it does not derive it.

Trade-off: cohort metric vs. point-in-time average

Cohort retention (group by signup week, track the share still active at week N) is immune to this bias because the denominator is fixed at signup. It is the right default for any retention claim. The point-in-time active-user average is cheaper to compute and is the right metric when the question is genuinely about the current active base, such as capacity planning. Deciding criterion: does the decision depend on users who left? If yes, cohort; if no, point-in-time, labelled as such.

Failure mode and detection

The subtle version: status = 'active' is itself defined as "logged in within 30 days," so the filter selects on recency, not just on churn. Detection: read the status definition in the schema; if it references a recent-activity window, the survivor average is biased upward by construction. Signal: the gap between survivor_avg and all_users_avg widens whenever a retention change ships.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-25

How would you document communicating uncertainty so the next owner can operate it?

Answer

Document uncertainty where the decision is made, not where the analysis lives. A bound in a notebook nobody opens at 3 a.m. is not documentation; a bound in the runbook next to the alert is. So the first move is to name the decision the number feeds (scale the pool, page someone, ship the change) and write the uncertainty in the form that decision consumes.

Concretely, every uncertain figure gets four things: the estimate, the interval, the sample it came from, and the threshold at which the next owner should act differently. The interval is what makes the threshold meaningful. A p99 of 180 ms with a bootstrap 95% CI of [140, 260] ms against a 250 ms SLO reads as "inside budget, but the interval crosses it: re-measure before you cut the pool." The same 180 ms with n = 200 requests says nothing, because a p99 from 200 samples is dominated by which requests happened to be slow.

A handover entry that an on-call can act on (figures hypothetical):

checkout-api p99, 2024-06-11, commit 9f3c1ab
  estimate   183 ms   bootstrap 95% CI [141, 262] ms
  sample     2.1M requests, 6h peak window (14:00-20:00 UTC)
  SLO        250 ms
  read       inside budget, but CI crosses SLO -> do not raise pool_max
             above 20 without re-measuring; window excludes month-end batch
  expires    re-measure after any change to pool_max or the DB driver
  owner      @payments-oncall

Three levels of fidelity, and the criterion that picks between them: reversibility of the decision, and whether a numeric threshold exists:

FidelityWhat you writeCostRight when
Label"confidence: low"secondsaction is reversible and cheap to undo
Estimate + interval + none line, as aboveminutesdefault for SLO, capacity and experiment calls
Per-segment intervalsinterval per cohort or regionhoursthe aggregate hides a segment already breaching

If the action is "roll back," a label is enough. If the action is "provision 30% more capacity," you need the interval, because the next owner is spending money on your number.

Write it in the operator's vocabulary. "The interval crosses the SLO" is actionable; "p = 0.07" is not, and neither is "results were mixed." The next owner needs to know what you measured, over what window, and what would change your mind.

Failure modes, and how each is caught:

  • Uncertainty with no threshold. "Latency is variable" tells the operator nothing to do. Detect it by asking the on-call what they would do differently if the number doubled; no answer means the note failed.
  • Stale bound. A CI measured before a config change is read as current. Pin the note to a commit SHA and re-open it when that config changes.
  • False precision. "p99 = 183.4 ms" from 200 samples. Print n beside every estimate; if n is too small for the percentile, the interval is wider than the SLO gap and the decimal is decoration.
  • Uncertainty that never expires. No review date, so last quarter's bound is read as today's. Add an expiry field and a reminder owned by a named person.

The test of the document is not whether it is honest about what you don't know. It is whether the next owner, reading it cold, can tell which action is safe now and which one needs a fresh measurement first.

Curated: · Written: · Reviewed:

Difficulty: Medium