Skip to content
Tactiverge

Textbooks/Engineering Research and Experimental Methods/Chapter 7Lite (plain text) version

7Inference done right

Version 1 · Technically checked (automated checks only) · 4 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Measurement and uncertainty
  2. 2. Designing fair experiments
  3. 3. Baselines and ablations
  4. 4. Research questions and hypotheses
  5. 5. Reading the literature
  6. 6. Power, pre-registration and reproducibility
  7. 7. Inference done right
  8. 8. Reporting and defending results

Introduction

Statistics cannot tell you that an idea is true, but it can tell you how surprising your data would be if it were not, and how large the effect plausibly is. This chapter reports standard errors and confidence intervals, interprets p-values correctly alongside effect sizes, counts the hidden tests behind flexible analyses, and uses the bootstrap to get intervals from your own data when formulas run out.

P(at least one false alarm) = 1 − 0.95^mm = 15 %m = 314.3 %m = 626.5 %m = 2064.2 %Every extra analysis path is another test.Pre-register, or correct for the number of tests.
Figure 7.1. Every analysis path is a test. Bars of the chance of at least one false positive among m independent tests at α = 0.05: 5 % for m = 1, 14.3 % for m = 3, 26.5 % for m = 6 and 64.2 % for m = 20. Trying many analyses until one works makes a false discovery likely.

Explanation

This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

7.1 Standard errors and confidence intervals

'The new method is 0.3 s faster.' Plus or minus what? Without that, the sentence means almost nothing.

SD versus SE

The standard deviation s describes how much single runs vary. The standard error s/√n describes how much the mean would vary if you repeated the whole experiment. Error bars must say which they show; SE bars are √n times shorter.

What 95% confidence means

If you repeated the experiment many times and built an interval each time, about 95% of those intervals would contain the true value. It does not mean there is a 95% probability the true value is in this particular interval, although for practical decisions the interval is your best summary of plausible values.

Small samples

With fewer than about 30 runs per group, replace 1.96 by the t critical value (for 10 degrees of freedom it is 2.23). Intervals get wider, honestly reflecting less information.

Derivation: Standard error of a difference
  1. Let X̄₁ and X̄₂ be means of independent samples, sizes n₁ and n₂, SDs σ₁ and σ₂.

  2. Var(X̄ᵢ) = σᵢ²/nᵢ, because averaging n independent runs divides the variance by n.

  3. For independent random variables, Var(X̄₁ − X̄₂) = Var(X̄₁) + Var(X̄₂): the minus sign does not cancel variance.

  4. So SE_diff = √(σ₁²/n₁ + σ₂²/n₂), estimated with sample SDs s₁, s₂.

  5. Approximate 95% CI: (x̄₁ − x̄₂) ± 1.96 · SE_diff for large samples; use the t critical value with Welch degrees of freedom for small ones.

  6. Paired designs (same seed for both methods) use the SD of the per-seed differences instead, which is often much smaller.

Common mix-ups

  • The SE of a difference is the sum of the two SEs.
    ✓ For independent estimates you add variances, so SE_diff = √(SE₁² + SE₂²), which is smaller than SE₁ + SE₂.

Open the full lesson: Standard errors and confidence intervals →

7.2 p-values and effect sizes, done correctly

p = 0.03. Does that mean a 3% chance your result is a fluke? (No. But almost everyone thinks so.)

The definition

The p-value is the probability, assuming the null hypothesis and the model are true, of obtaining a test statistic at least as extreme as the one observed. Small p means the data would be surprising under the null. That is all.

Three misreadings

  1. p is not the probability that the null is true. 2. p > 0.05 does not show there is no effect (it may be low power). 3. p does not measure importance: with enough runs, trivial effects reach tiny p. Report the estimate, its interval and an effect size alongside p.

t and d

The t statistic = difference / SE_diff: how many standard errors the difference is from zero. It grows with √n. Cohen's d = difference / pooled SD: the difference in units of run-to-run spread. It does not grow with n, so it is the better measure of size.

Common mix-ups

  • A smaller p-value means a bigger or more important effect.
    ✓ p mixes effect size with sample size. Report the effect size and interval to say how big the effect is.

Open the full lesson: p-values and effect sizes, done correctly →

7.3 Module check: forking paths and multiple comparisons

Nothing in this simulation has any real effect. Yet with a few innocent choices, a third of studies 'find' one. How?

The garden of forking paths

Which outcome, which outlier rule, which subgroup, when to stop: each choice is a fork. If choices are made after looking at data, the analysis effectively tries many paths and reports one. The nominal 5% then hugely understates the real false-positive rate, even with no intent to deceive.

p-hacking and HARKing

p-hacking: trying analyses until p < 0.05. HARKing: Hypothesising After the Results are Known, presenting a post-hoc pattern as if predicted. Both are questionable research practices that manufacture findings. Remedies: pre-registration, one primary analysis, corrections for planned multiple tests, and labelling the rest exploratory.

Expected false discoveries

Run m null tests at α and expect m·α false positives. If only a fraction of ideas are true, the share of significant results that are false can be large: with 90 null and 10 real ideas, α = 0.05 and power 0.8, there are 4.5 false versus 8 true hits, so 36% of 'discoveries' are false.

Derivation: Bonferroni from the union bound
  1. Let Eᵢ be the event 'test i is a false positive', with P(Eᵢ) = α* for each of m null tests.

  2. Family-wise error rate FWER = P(E₁ ∪ … ∪ E_m).

  3. Union bound: P(∪Eᵢ) ≤ Σ P(Eᵢ) = m·α*, whatever the dependence between tests.

  4. Choose α* = α/m. Then FWER ≤ m · α/m = α.

  5. For independent tests the exact rate is 1 − (1 − α/m)^m, slightly below α.

  6. Cost: each test is stricter, so power falls. For many tests, false-discovery-rate methods trade a few false positives for more power.

Common mix-ups

  • p-hacking requires deliberately cheating.
    ✓ It usually happens through many reasonable-looking choices made after seeing the data; good intentions do not prevent it, pre-registration does.

Open the full lesson: Module check: forking paths and multiple comparisons →

7.4 The bootstrap: uncertainty from your own data

Your metric is a median of skewed settling times. There is no neat formula for its standard error. Can the data tell you instead?

Resample, recompute, repeat

Treat your sample as a stand-in for the population. Draw n values from it with replacement, compute the statistic, and repeat a thousand times. The histogram of results shows how uncertain the statistic is. For a mean it agrees closely with s/√n; for medians and ratios it gives answers formulas cannot.

Comparing two methods

For a difference, resample each group separately (or resample paired seeds together), compute the difference each time, and take the 2.5% and 97.5% quantiles. Record the bootstrap seed: bootstrap intervals are random too, and should be reproducible.

Where it fails

The bootstrap assumes runs are independent and the sample represents the population. With very small n (under about 10), heavy tails or dependent runs (time series), the interval can be too narrow. It never corrects a biased sample or a confounded design.

Derivation: The bootstrap idea
  1. We want the sampling distribution of a statistic θ̂ (e.g. the median): how it would vary over new datasets of size n.

  2. We cannot draw new datasets from the true population F.

  3. Plug-in principle: replace F by the empirical distribution F̂ that puts mass 1/n on each observed value.

  4. Drawing n values from F̂ = resampling the data with replacement. Compute θ̂* on each resample.

  5. Repeat B times (B ≈ 1000–10,000). The spread of the θ̂* estimates the spread of θ̂: SE_boot = SD(θ̂*).

  6. Percentile interval: the 2.5% and 97.5% quantiles of θ̂*. Assumes the sample represents the population; it cannot fix bias or a tiny n.

Common mix-ups

  • The bootstrap creates extra data, so small samples become reliable.
    ✓ It only reuses the data you have; it estimates uncertainty, it cannot reduce it or fix a biased sample.

Open the full lesson: The bootstrap: uncertainty from your own data →

Worked examples

Standard errors and confidence intervals: example 1

Baseline 2.40 s (s 0.30, n 25); new 2.15 s (s 0.35, n 25). 95% CI of the improvement?

Solution

SE = √(0.09/25 + 0.1225/25) = √0.0085 = 0.0922 s. Improvement 0.25 s ± 1.96 × 0.0922 = ± 0.181 → [0.069, 0.431] s.

p-values and effect sizes, done correctly: example 1

n = 50 each, d = 0.1. What is t, roughly, and is the effect important?

Solution

t ≈ 0.1 × √25 = 0.5, not significant. With n = 5000 each, t ≈ 0.1 × 50 = 5, p < 0.001, but d is still 0.1: a tiny effect relative to spread. Importance depends on the requirement, not on p.

Module check: forking paths and multiple comparisons: example 1

You pre-register 4 metrics as co-primary. What threshold per test keeps FWER at 0.05?

Solution

Bonferroni: 0.05 / 4 = 0.0125. A metric with p = 0.02 is not significant under this plan, and you report it as such.

The bootstrap: uncertainty from your own data: example 1

1000 bootstrap medians, sorted: the 25th is 2.18 s and the 975th is 2.52 s. Interval?

Solution

Percentile 95% CI ≈ [2.18, 2.52] s (the 2.5% and 97.5% quantiles of 1000 values sit near positions 25 and 975).

Interactive figures

Figure 7.2 from Standard errors and confidence intervalsIn the top panel, keep the difference at 0.3 and shrink the SE: watch the interval tighten. In the lower panel, set the true difference to 0.2 and run several sets of 20 replications. Count how many intervals miss the truth each time.
Can't use the interactive? Read a description instead

The top panel draws an estimate as a dot with a horizontal 95% interval, a dashed zero line and a green line for the smallest effect of interest. The lower panel draws 20 replicated intervals around a true value; intervals that miss it are shown dashed in red, and the readout counts them.

Interactive figure (online). Description: The top panel draws an estimate as a dot with a horizontal 95% interval, a dashed zero line and a green line for the smallest effect of interest. The lower panel draws 20 replicated intervals around a true value; intervals that miss it are shown dashed in red, and the readout counts them.

Figure 7.3 from Module check: forking paths and multiple comparisonsStart with every switch off: the false-positive rate is near 5%. Turn on one fork at a time and note the rate. Turn them all on. Then switch on the Bonferroni correction. Which single fork inflated the rate most?
Can't use the interactive? Read a description instead

The forking-paths simulator runs 400 seeded studies in which there is no real effect. Switches add analysis choices (three outcomes, outlier removal, subgroups, peeking). A bar shows the share of studies reporting a 'significant' finding against a marked 5% line. With all switches on it is far above 5%; a Bonferroni switch brings it back near 5%.

Interactive figure (online). Description: The forking-paths simulator runs 400 seeded studies in which there is no real effect. Switches add analysis choices (three outcomes, outlier removal, subgroups, peeking). A bar shows the share of studies reporting a 'significant' finding against a marked 5% line. With all switches on it is far above 5%; a Bonferroni switch brings it back near 5%.

Figure 7.4 from The bootstrap: uncertainty from your own dataDo one resample and read the ×counts. Then +1000. Compare the bootstrap SE of the mean with the formula s/√n. Switch to the median: what does the histogram look like now? Reset with a new seed: how stable is the interval?
Can't use the interactive? Read a description instead

The bootstrap resampler shows the original values, how many times each was drawn in the latest resample, and a histogram of resampled means or medians with the observed value and the 95% percentile interval marked. Buttons add 1, 100 or 1000 resamples.

Interactive figure (online). Description: The bootstrap resampler shows the original values, how many times each was drawn in the latest resample, and a histogram of resampled means or medians with the observed value and the 95% percentile interval marked. Buttons add 1, 100 or 1000 resamples.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

  • Equation Lab exploration

    Equation Lab: Compare

    Compare two simulated samples and read the difference, its interval, the effect size and the p-value side by side.

    Open Equation Lab: Compare →
  • Studio

    Code Lab

    Bootstrap a 95 % interval for a median from simulated timings, recording the seed, and compare it with a normal-theory interval.

    Open Code Lab →

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

Which interpretation of a 95% CI is correct?

Practice 2

Error bars labelled 'SD' on 100 runs. Compared with SE bars they are…

Practice 3

Paired design: per-seed differences have SD 0.12 s over 16 seeds. SE of the mean difference?

s

Practice 4

Which statement about p = 0.01 is correct?

Practice 5

p = 0.4 in a study of 6 runs per group. What can you conclude?

Practice 6

Checking the p-value after every 5 runs and stopping when p < 0.05 is a problem because…

Practice 7

Which is the best remedy for forking paths?

Practice 8

When is a bootstrap interval least trustworthy?

  1. Which interpretation of a 95% CI is correct?
    • 95% of runs fall inside it
    • The procedure captures the true value in about 95% of repeated experiments
    • There is a 95% chance the hypothesis is true
    • The p-value is 0.95
  2. Error bars labelled 'SD' on 100 runs. Compared with SE bars they are…
    • The same
    • 10 times longer
    • 10 times shorter
    • 100 times longer
  3. Paired design: per-seed differences have SD 0.12 s over 16 seeds. SE of the mean difference? (s)
  4. Which statement about p = 0.01 is correct?
    • There is a 1% chance the null is true
    • Under the null, results this extreme occur about 1% of the time
    • The effect is 99% certain
    • The effect is large
  5. p = 0.4 in a study of 6 runs per group. What can you conclude?
    • There is no effect
    • The study could not distinguish the effect from noise; check the interval
    • The method is worse
    • The null is 40% likely
  6. Checking the p-value after every 5 runs and stopping when p < 0.05 is a problem because…
    • It wastes time
    • Each peek is another chance for noise to cross the line, inflating false positives
    • It reduces sample size too much
    • It is fine
  7. Which is the best remedy for forking paths?
    • Use a smaller α but keep choosing after seeing data
    • Pre-register one primary analysis and label everything else exploratory
    • Report only significant results
    • Collect less data
  8. When is a bootstrap interval least trustworthy?
    • n = 200 independent runs
    • n = 5 runs with one extreme value
    • A mean of 50 runs
    • Paired seeds

Engineering applications

  • Many sensors, many tests

    Checking twenty sensor channels for a change at α = 0.05 will usually flag one by chance. Controlling the false discovery rate keeps the alarm list honest.

  • Skewed timing data

    Response times have long tails, so a mean and a normal interval mislead. A bootstrap interval for the median reflects the data's real shape.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

A careful definition of what a p-value is (and is not), with a worked example of when a small one should still not convince you.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Walks through how trying many analyses and reporting the one that worked manufactures false positives, and what pre-registration does about it.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Shows with a histogram of p-values why thousands of tests produce many false positives and how a false discovery rate correction controls them.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Builds the bootstrap from scratch: resample your own data with replacement, recompute the statistic, and read its spread as uncertainty.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • p-values: What they are and how to interpret them (StatQuest with Josh Starmer)
  • P-Hacking: Crash Course Statistics #30 (CrashCourse)
  • False Discovery Rates, FDR, clearly explained (StatQuest with Josh Starmer)
  • Bootstrapping Main Ideas!!! (StatQuest with Josh Starmer)

Chapter summary

  • Report the estimate, its interval and an effect size; a p-value alone says little.
  • p is the probability of data at least this extreme if the null were true, not the probability the null is true.
  • Flexible analyses, peeking and selective reporting multiply the chance of false positives.
  • Correct for multiple comparisons or pre-register a single primary analysis.
  • The bootstrap resamples your data with replacement to estimate uncertainty; record its seed.

Glossary

Standard error of the mean
The standard error of the mean estimates how much a sample mean would vary between repeated experiments: the sample standard deviation divided by the square root of the number of readings.
Repeated trials
Repeating a measurement or test several times shows how much results vary and lets you average out random error.
Outliers and honest data
An outlier is a reading far from the rest. It may be a genuine effect or a fault; either way it must be investigated and reported, and any exclusion rule decided before seeing the results.

Definitions from the Field Guide.

Project: Analyse a simulated study three ways

For a two-condition comparison run in a School simulation, report the difference with a normal-theory interval, a bootstrap interval and a p-value with an effect size. Then show how many results would look significant if you had tested every outcome you recorded.

Deliverables

  • Three analyses of the same simulated data
  • A multiple-comparison count and correction
  • A plain-language statement of what can be concluded

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • Ronald L. Wasserstein and Nicole A. Lazar (2016). "The ASA's Statement on p-Values: Context, Process, and Purpose". The American Statistician 70(2), 129–133.
  • Joseph P. Simmons et al. (2011). "False-Positive Psychology: Undisclosed Flexibility in Data Collection and Analysis Allows Presenting Anything as Significant". Psychological Science 22(11), 1359–1366.
  • Yoav Benjamini and Yosef Hochberg (1995). "Controlling the False Discovery Rate: A Practical and Powerful Approach to Multiple Testing". Journal of the Royal Statistical Society, Series B 57(1), 289–300.
  • Bradley Efron and Robert J. Tibshirani (1993). An Introduction to the Bootstrap. Chapman & Hall.

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.