4. Introduction to Confidence Intervals

a. The Bootstrap Distribution

Yurk

Two Types of Questions

Hypothesis Testing: Is a specific value plausible?

  • Medical consultant: “Is her complication rate below the 10% national average, or is 10% plausible?”
  • We tested H_0: p = 0.10
  • Answer: Reject or fail to reject H_0 — here, 10% is plausible

Today (Confidence Intervals): Given the data, what are all the plausible values for p?

  • Medical consultant: “What IS her complication rate?”
  • Answer: An interval estimate — e.g., “her complication rate is plausibly between 1% and 12%”

Candidate X

Context: Candidate X is running for mayor. Her campaign wants to estimate p, the proportion of all voters who support her.

Data: Campaign polls a random sample of 30 voters

  • 21 people support Candidate X
  • \hat{p} = \frac{21}{30} = 0.7 (70%)

This single number is our point estimate for p — our best guess from the data, but not the whole story.

Question: Given the data, what are other plausible values for p?

What Makes a Value Plausible for p?

A value is plausible for p if it could reasonably produce a \hat{p} like ours.

How close to \hat{p} does it have to be?

  • If \hat{p} varies only a little from sample to sample → only values very close to \hat{p} are plausible
  • If \hat{p} varies a lot → a wider range of values is plausible

The key quantity: how much \hat{p} varies from sample to sample.

Treat the Sample as the Population

How can we measure \hat{p}’s variability — from the data we already have?

To simulate \hat{p}’s variability, we’d want to repeatedly draw new samples from the population. We don’t have the population — but our sample is the best approximation of it we’ll ever get.

Idea: Treat the sample as a stand-in for the population, and draw new samples from it.

Bootstrap Sampling

Picture it physically. Write each person’s vote on its own slip of paper — 30 slips total — and drop them all in a hat.

To build one bootstrap sample:

  1. Draw a slip and record the vote
  2. Put the slip back
  3. Repeat until you’ve drawn 30 slips

The result is a new pretend-sample of 30 votes: the same voter can appear multiple times, others not at all.

This is sampling with replacement. Applied to our own sample, it’s called bootstrap sampling (or bootstrapping).

Why Does Bootstrapping Work?

The logic:

  1. Our sample reflects the population structure (it was drawn from it)
  2. Sampling with replacement from the sample recreates the “luck of the draw” of getting different samples
  3. The variation across bootstrap samples approximates how \hat{p} varies across real samples — not from an assumed value of p

Build a Bootstrap Sample

Activity: Create your own bootstrap sample

Original sample data: 30 voters (next slide shows the data)

Instructions:

  1. Go to random.org/integers
  2. Generate 30 random integers between 1 and 30
  3. Look up each ID in the table → find their vote
  4. Count how many “yes” votes in your bootstrap sample
  5. Calculate \hat{p}_{boot} = \frac{\text{yes votes}}{30}

Original Sample Data

ID Vote
1 yes
2 yes
3 yes
4 no
5 yes
6 yes
7 yes
8 yes
9 no
10 yes
11 yes
12 yes
13 no
14 yes
15 yes
ID Vote
1 yes
2 yes
3 yes
4 no
5 yes
6 yes
7 yes
8 yes
9 no
10 yes
11 yes
12 yes
13 no
14 yes
15 yes
ID Vote
16 yes
17 yes
18 no
19 yes
20 yes
21 yes
22 no
23 no
24 no
25 yes
26 yes
27 yes
28 no
29 yes
30 no
ID Vote
16 yes
17 yes
18 no
19 yes
20 yes
21 yes
22 no
23 no
24 no
25 yes
26 yes
27 yes
28 no
29 yes
30 no

Your random integers/IDs:
25, 4, 7, 1, 2, 29, 23, 11, 14, 18, 27, 19, 1, 21, 21, 10, 22, 14, 10, 7, 9, 15, 21, 5, 9, 25, 14, 5, 5, 2

Votes for your bootstrap sample (Y/N):
Y, N, Y, Y, Y, Y, N, Y, Y, N, Y, Y, Y, Y, Y, Y, N, Y, Y, Y, N, Y, Y, Y, N, Y, Y, Y, Y, Y

Your x: 24

Your \hat{p}_{boot}: 24/30 = 0.8

What Does Each Bootstrap p̂ Represent?

What does your \hat{p}_{boot} represent?

One example of what \hat{p} might have been from another sample like ours — drawn (with replacement) from our 30 voters.

What does the second \hat{p}_{boot} (the one we computed together) represent?

The same kind of thing — another example of \hat{p}, from a different resample.

If we repeat this process many times, we create a bootstrap distribution — a picture of how \hat{p} varies from sample to sample.

Build the Distribution

Where does your \hat{p}_{boot} appear on this plot?

Let’s add the one we calculated together.

Advance to add more…

Interactive Bootstrap Demo

Optional — try the interactive simulation to see the bootstrap distribution build up live:

🎯 Open Bootstrap Demo

  • Run 1 sample at a time and watch the resampling animation
  • Run 100 samples to quickly build the bootstrap distribution
  • See how bootstrap proportions stack up in the dotplot

The Bootstrap Distribution (1000 Samples)

Histogram of 1000 bootstrap proportions. Distribution centered near 0.7 (our observed \hat{p}).

Bootstrap vs Null Distribution

Same simulation tool — but the anchor is different, so the two distributions sit in different places relative to our observed \hat{p}.

The dashed line marks our observed \hat{p} \approx 0.7. It lands in the tail of the null distribution, but at the center of the bootstrap distribution.

The Percentile Method

To create a 95% confidence interval:

  1. Take the bootstrap distribution
  2. Find the middle 95% of values
  3. Cutoffs: 2.5th percentile and 97.5th percentile

Why these percentiles?

  • 2.5% below, 95% in the middle, 2.5% above
  • These values “fence in” the middle 95%

Computing the 95% CI

95% Confidence Interval: (0.533, 0.834)

Why Does This Give a CI?

Each \hat{p} is a dart; the truth p is the bullseye. 95% of darts land within some distance of the bullseye — the bootstrap tells us roughly what that distance is. So we draw a circle of that radius around our dart, and the bullseye is plausibly inside.

That’s our 95% CI.

References