# 📐 Sampling, Confidence Intervals and Hypothesis Tests

By Better Wise

> This lesson is premium content. Sign in and purchase the course to view the full content.

The previous lesson split prediction error into bias and variance. This lesson moves from model error to estimate error: you have one sample, one estimate, and a decision to make. We will use a delivery-time dataset question to build a confidence interval and run a one-sample test, then pin down what a p-value does and does not mean.

**What you will be able to do**
- Explain why a sample mean varies and estimate its standard error.
- Build and interpret a 95% confidence interval for a mean.
- Run a one-sample t-test and state the p-value correctly.
- Separate statistical significance from practical importance.

### A Delivery-Time Dataset Question

A regional delivery team records 64 completed orders. The sample mean delivery time is 31 minutes, and the sample standard deviation is 8 minutes. The business question is simple: is the average delivery time above the 28-minute service target?

The sample mean is one draw from a sampling distribution, not the population mean itself. If we repeated the study with new random samples of 64 orders, the mean would move. The standard error of the sample mean estimates that movement:

$\mathrm{SE} = s / \sqrt{n} = 8 / \sqrt{64} = 1$ minute.

With independent orders and finite variance, the central limit theorem makes the sampling distribution of the mean approximately normal for $n = 64$, even if individual delivery times are skewed.

### A 95% Confidence Interval for Mean Delivery Time

Because $\sigma$ is unknown, use the t critical value with $n - 1 = 63$ degrees of freedom. The 95% interval is:

$$
\bar{x} \pm t^* \frac{s}{\sqrt{n}}
$$

With $t^*$ about 2.00, the interval is 31 plus or minus 2.00(1), or (29.0, 33.0) minutes.

The correct reading: if we repeated this sampling and interval construction many times, about 95% of the intervals would contain the true mean delivery time. The interval does not contain 95% of individual deliveries, and the computed interval is not a 95% probability statement about a fixed unknown mean.

## In this lesson

- A Smaller Sample Widens the Interval
- One-Sample Test: Is the Mean Above 28 Minutes?
- What a p-value Actually Says
- Review Deck: Sampling and Inference
- What to Keep and Where We Go Next


---

## Contents

Part of [🎲 Mathematics for Machine Learning 3: Probability and Statistics for Data-Driven Models](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data.md)

- **🎲 Probability Foundations for Data**
  - [🧩 Axioms, Conditional Probability and Independence](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/probability-axioms-conditional-independence.md)
  - [📊 Expectation and Variance on a Real Dataset](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/expectation-variance-worked-dataset.md) (sign-in required)
  - [🔗 Covariance, Correlation and Dependence](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/covariance-correlation-dependence.md)
  - [✅ Checkpoint: Probability Foundations](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/checkpoint-probability-foundations.md)
- **📈 Distributions and Bayes' Rule**
  - [🔢 Bernoulli, Binomial and Poisson Counts](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/bernoulli-binomial-poisson-count-data.md)
  - [🔔 Gaussian and Exponential Models](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/gaussian-exponential-continuous-data.md)
  - [🧠 Bayes' Rule and Base Rates](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/bayes-rule-base-rates.md)
  - [🧪 Checkpoint: Distributions and Bayes](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/checkpoint-distributions-and-bayes.md)
- **🎯 Estimation and Inference**
  - [⚙️ Maximum Likelihood and MAP Estimation](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/maximum-likelihood-map-estimation.md)
  - [⚖️ Bias-Variance Tradeoff in Practice](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/bias-variance-tradeoff-practice.md)
  - [📐 Sampling, Confidence Intervals and Hypothesis Tests](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/sampling-confidence-intervals-hypothesis-tests.md) (premium content) — this lesson
  - [🏁 Checkpoint: Estimation and Inference](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/checkpoint-estimation-and-inference.md) (premium content)
- [Course cheatsheet](https://everwise.study/courses/mathematics-for-machine-learning-3-probability-and-statistics-for-data/cheatsheet.md) (premium content)
