TEC-DATA85-02 · Lesson 6 · 14 clock hours · lab
Confidence Intervals and Hypothesis Testing
Objective. Students construct 90%, 95%, and 99% confidence intervals for a mean and proportion and perform one-sample z- and t-tests, correctly stating null and alternative hypotheses and interpreting p-values.
⚠ Pending professional review
This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.
VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.
Confidence Intervals and Hypothesis Testing
Why These Tools Matter
Data analysts are constantly asked to draw conclusions from samples rather than entire populations. Two foundational statistical tools make that possible: confidence intervals and hypothesis tests. Both appear in the CompTIA Data+, Google Data Analytics, and IBM Data Science Professional credential exams, and both are skills you will use on the job every week.
---
Confidence Intervals
A confidence interval (CI) gives a range of plausible values for a population parameter (like a mean or proportion) based on sample data. It has three parts:
1. Point estimate — the sample statistic (sample mean x̄ or sample proportion p̂).
2. Margin of error (ME) — how far the interval extends on each side.
3. Confidence level — how often intervals built this way would capture the true parameter if sampling were repeated many times (common choices: 90%, 95%, 99%).
The general formula is:
```
CI = point estimate ± (critical value × standard error)
```
Standard error for a mean: SE = s / √n (use population σ if known; otherwise use sample s).
Standard error for a proportion: SE = √(p̂(1 − p̂) / n).
Critical values (z\*) for common confidence levels:
- 90% → z\* = 1.645
- 95% → z\* = 1.960
- 99% → z\* = 2.576
When the population standard deviation is unknown and the sample is small (commonly n < 30), use a t-distribution critical value instead, with degrees of freedom = n − 1.
Interpreting a CI correctly: A 95% CI does not mean there is a 95% probability the true mean is in this interval. It means that the method produces intervals that capture the true parameter in 95% of repeated samples. State it as: "We are 95% confident that the true population mean falls between [lower] and [upper]."
---
Hypothesis Testing — The Framework
Hypothesis testing is a formal decision procedure. You start with a default assumption and ask whether the data give enough evidence to reject it.
Step 1 — State the hypotheses.
- Null hypothesis (H₀): The "no effect" or "status quo" statement. Always contains an equality (=, ≤, or ≥).
- Alternative hypothesis (Hₐ): What you are trying to support. Can be two-tailed (≠), left-tailed (<), or right-tailed (>).
Step 2 — Choose significance level α. The most common choice is α = 0.05.
Step 3 — Select the test statistic.
- Use a z-test when σ (population SD) is known, or when n ≥ 30 (by the Central Limit Theorem).
- Use a t-test when σ is unknown and n < 30.
Step 4 — Compute the test statistic.
- z = (x̄ − μ₀) / (σ / √n)
- t = (x̄ − μ₀) / (s / √n)
Step 5 — Find the p-value and compare to α.
- If p-value ≤ α: reject H₀. The result is statistically significant.
- If p-value > α: fail to reject H₀. Insufficient evidence.
Step 6 — State a plain-language conclusion tied to the original question.
In Python, `scipy.stats` handles this cleanly:
```python
from scipy import stats
t_stat, p_value = stats.ttest_1samp(data_column, popmean=50000)
```
---
Common p-Value Misconceptions
The p-value is the probability of obtaining a test statistic at least as extreme as the observed one, assuming H₀ is true. It is NOT:
- The probability that H₀ is true.
- The probability that the result occurred by chance.
- A measure of practical importance or effect size.
A statistically significant result (small p) can be practically meaningless, especially with very large samples. Always pair statistical significance with effect size or business context.
---
Data Safety and Professional Practice
City employee salary data and similar government datasets are public records, but always verify the data use policy of any portal before downloading. When working with data that could be linked to individuals:
- Do not share raw data files outside your authorized environment.
- Follow your organization's data governance policy.
- In Python, avoid printing individual rows in shared notebooks; summarize instead.
While this is not a physical-hazard lab, data integrity is your equivalent of worksite safety: decisions made on incorrectly processed data can harm real people through misallocated budgets, discriminatory patterns, or flawed policy.
---
Putting It Together
For today's lab you will load a city employee salary CSV, state a claim about the mean annual salary, build a confidence interval, and run a one-sample t-test in Python. Each step maps directly to the six-step framework above. Keep your rubric (12 points, 75% to pass) in front of you: hypotheses, test selection, computation, and plain-language conclusion each carry points.
Key terms10
Confidence Interval (CI)A range of values, computed from sample data, that is expected to contain the true population parameter a stated percentage of the time under repeated sampling.
Point EstimateA single sample statistic (such as the sample mean or sample proportion) used as the best single guess for the population parameter.
Margin of Error (ME)The product of the critical value and the standard error; it defines how far the confidence interval extends above and below the point estimate.
Null Hypothesis (H₀)The default assumption in hypothesis testing, stating no effect or no difference; it always includes an equality and is the statement being tested.
Alternative Hypothesis (Hₐ)The research claim the analyst is trying to support; it is accepted only when there is sufficient evidence to reject H₀.
p-valueThe probability of observing a test statistic as extreme as or more extreme than the one computed, assuming the null hypothesis is true; a small p-value suggests the data are inconsistent with H₀.
Significance Level (α)The pre-specified threshold below which a p-value leads to rejection of H₀; the most common choice is 0.05, meaning a 5% acceptable rate of false positives.
t-distributionA symmetric, bell-shaped probability distribution with heavier tails than the normal distribution, used when the population standard deviation is unknown and the sample is small.
Standard Error (SE)The standard deviation of the sampling distribution of a statistic; for a mean it equals s divided by the square root of n, and it measures how much the sample statistic varies from sample to sample.
Type I ErrorRejecting a true null hypothesis; its probability equals α. Analysts control it by choosing a small significance level before collecting data.
Worked examples4
1. A sample of 36 city employees has a mean annual salary of $54,200 with a sample standard deviation of $8,400. Build a 95% confidence interval for the population mean salary.
- Identify the point estimate: x̄ = 54,200.
- Compute the standard error: SE = s / √n = 8,400 / √36 = 8,400 / 6 = 1,400.
- Select the critical value: n = 36 ≥ 30 so use z*. For 95%, z* = 1.960.
- Compute the margin of error: ME = z* × SE = 1.960 × 1,400 = 2,744.
- Build the interval: Lower = 54,200 − 2,744 = 51,456; Upper = 54,200 + 2,744 = 56,944.
- Interpret: We are 95% confident that the true mean annual salary of all city employees falls between $51,456 and $56,944.
Answer: 95% CI: ($51,456 ; $56,944)
2. A poll of 400 residents finds that 220 support a proposed budget measure. Build a 90% confidence interval for the true population proportion who support it.
- Compute the sample proportion: p̂ = 220 / 400 = 0.55.
- Compute the standard error: SE = √(p̂(1 − p̂) / n) = √(0.55 × 0.45 / 400) = √(0.2475 / 400) = √0.00061875 ≈ 0.02488.
- Select the critical value: For 90%, z* = 1.645.
- Compute the margin of error: ME = 1.645 × 0.02488 ≈ 0.04093.
- Build the interval: Lower = 0.55 − 0.041 = 0.509; Upper = 0.55 + 0.041 = 0.591.
- Interpret: We are 90% confident that between 50.9% and 59.1% of all residents support the budget measure.
Answer: 90% CI for proportion: (0.509, 0.591)
3. A data analyst claims that the mean salary of city engineers is greater than $70,000. A sample of 25 engineers has x̄ = $72,500 and s = $6,000. Test this claim at α = 0.05.
- State hypotheses: H₀: μ ≤ 70,000 ; Hₐ: μ > 70,000 (right-tailed test).
- Select the test: σ is unknown and n = 25 < 30, so use a one-sample t-test with df = 25 − 1 = 24.
- Compute the test statistic: t = (x̄ − μ₀) / (s / √n) = (72,500 − 70,000) / (6,000 / √25) = 2,500 / (6,000 / 5) = 2,500 / 1,200 ≈ 2.083.
- Find the p-value: For t = 2.083, df = 24, one-tailed, the p-value ≈ 0.024 (from t-table or scipy.stats.ttest_1samp).
- Compare to α: p-value (0.024) < α (0.05), so reject H₀.
- Conclude: There is sufficient evidence at the 5% significance level to support the claim that the mean salary of city engineers is greater than $70,000.
Answer: t ≈ 2.083, p ≈ 0.024; reject H₀. Evidence supports mean salary > $70,000.
4. A random sample of 9 analyst salaries has x̄ = $61,000 and s = $4,500. Build a 99% confidence interval for the population mean. (Use t* for df = 8; t* ≈ 3.355.)
- Identify: x̄ = 61,000, s = 4,500, n = 9, df = 8, confidence level = 99%.
- Compute SE: SE = 4,500 / √9 = 4,500 / 3 = 1,500.
- Use t* = 3.355 (df = 8, 99% two-tailed from t-table).
- Compute ME: ME = 3.355 × 1,500 = 5,032.50.
- Build interval: Lower = 61,000 − 5,032.50 = 55,967.50; Upper = 61,000 + 5,032.50 = 66,032.50.
- Interpret: We are 99% confident the true mean analyst salary falls between $55,967.50 and $66,032.50.
Answer: 99% CI: ($55,967.50, $66,032.50)
The math in this lesson2
Learners compute standard error, margin of error and a 95% confidence interval for a mean.
S-IC.4S-IC.5
In class: Worked-example lecture: instructor builds a confidence interval for a mean step by step (point estimate, standard error, critical value, margin of error) and interprets it; students then build one for a proportion using a provided poll dataset. · Hypothesis testing lab: using a real dataset (e.g., city employee salary data), students state H0 and Ha, select z-test or t-test based on sample size and known/unknown population SD, compute the test statistic in Python with scipy.stats, and state a conclusion at α = 0.05. · p-value misconception activity: students read three short paragraphs that misinterpret p-values (common published errors), identify the error in each, and write the correct interpretation; class debriefs together.
Materials: Jupyter Notebook, scipy.stats; city employee salary CSV (e.g., from a municipal open data portal); z-table and t-table handouts; p-value misconception article excerpts
Check: Hypothesis testing lab graded on a 12-point rubric: correct H0/Ha (2 pts), correct test selection (2 pts), correct computation (4 pts), correct conclusion and plain-language interpretation (4 pts); pass mark 75%.
Practice check8
Answer each question, then check it. Nothing is recorded; this is your own practice.
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.