Skip to content
Tutorials Center
My learning

Topics

Lesson 54 of 57 ยท Practice and Review

Practice Set: Distributions and Inference

Practice confidence intervals, z and t tests, two-sample and paired tests, proportions, chi-square, ANOVA, power and sample size with worked, runnable solutions.

This second practice set covers statistical inference: using a sample to say something about a population. As before, attempt each problem on paper first, then run the solutions. The solution code names every step (the statistic, the distribution, the decision), which is exactly the structure to follow in an exam or an analysis.

A reliable template for any test: (1) state Hโ‚€ and Hโ‚; (2) pick the test and check its conditions; (3) compute the statistic and p-value; (4) decide at your ฮฑ; (5) write the conclusion in the context of the problem, with an interval for the effect.

Part A: estimation

Problem 1. A sample of 36 batteries has mean life 52.4 hours and sd 6 hours. Build a 95% confidence interval for the true mean (use t). Interpret it.

Problem 2. In a poll of 400 people, 232 favor a proposal. Find the 95% CI for the population proportion. How many people would you need to poll to get a margin of error of 2 points (use p = 0.5 for the worst case)?

Problem 3. Using the sample in Problem 1, how would the interval change with a 99% level? With a sample of 144 and the same mean and sd?

Python Solutions for Part A

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Higher confidence widens the interval; a larger sample narrows it by โˆšn (quadrupling n halves the width). Interpretation: we are 95% confident, in the sense of the method capturing the true mean in 95% of repeated samples, that the average battery life is between about 50.4 and 54.4 hours.

Part B: tests for means and proportions

Problem 4. A machine should fill bottles with 500 ml. A sample of 25 bottles has mean 497.6 ml and sd 6.2 ml. Is there evidence the mean differs from 500? (ฮฑ = 0.05)

Problem 5. Two teaching methods are compared. Group A scores: 78, 82, 69, 91, 75, 84, 80, 77; group B: 85, 88, 79, 94, 90, 86, 83, 92. Is there a difference in mean scores?

Problem 6. Ten patients' blood pressure before and after a drug: before 150, 142, 160, 155, 148, 163, 152, 158, 145, 151, after 144, 140, 153, 150, 149, 155, 147, 150, 141, 148. Did the drug lower blood pressure?

Problem 7. A website claims at most 5% of visitors leave within 5 seconds. In 600 visits, 42 left. Test Hโ‚€: p = 0.05 against Hโ‚: p > 0.05.

Python Solutions for Part B

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Each conclusion should be written in words, for example Problem 6: "There is strong evidence that the drug lowers blood pressure; the average drop is about 5 mm Hg." For Problem 4 the p-value is above 0.05, so we do not have enough evidence that the filling machine is off target; that is not proof that it is exactly on target.

Part C: categorical data, ANOVA, power

Problem 8. A die is rolled 120 times with counts for faces 1 to 6 of 15, 25, 18, 22, 14, 26. Is it fair?

Problem 9. A survey cross-tabulates preferred device (phone, laptop) by age group (under 30, 30 and over): under 30 has 90 phone and 30 laptop; 30 and over has 60 phone and 60 laptop. Are device preference and age group independent?

Problem 10. Three fertilizers give yields: A 20, 22, 19, 24, 21, B 25, 27, 24, 28, 26, C 21, 23, 22, 20, 24. Test whether mean yields differ, and report the share of variance explained.

Problem 11. How many subjects per group are needed to detect a difference of 5 points between two means when the sd is 10, with ฮฑ = 0.05 and power 0.8?

Python Solutions for Part C

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The die in Problem 8 gives p of about 0.26, so the counts are consistent with a fair die even though they look uneven: random variation in only 120 rolls is large. In Problem 10 a significant ANOVA only says some group differs; a follow-up such as Tukey's test would show that fertilizer B is the best.

Part D: concept checks

Problem 12. True or false, and why? (a) "A 95% CI means there is a 95% chance the true mean is inside this particular interval." (b) "p = 0.03 means there is a 3% chance the null is true." (c) "A non-significant result proves there is no effect."

All three are false. (a) The 95% describes the long-run capture rate of the method; a specific computed interval either contains the true value or not. (b) The p-value is the probability of data this extreme if the null were true, not the probability that the null is true. (c) Not significant means the data did not provide enough evidence of an effect; the study may have lacked power, so look at the interval.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. You quadruple the sample size. What happens to the width of a confidence interval for a mean, roughly?

    The standard error is s divided by the square root of n, so 4 times the sample size halves it.
  2. 2. Which test fits paired before-and-after measurements on the same subjects?

    Pairing removes between-subject variation; test the differences within each subject.
  3. 3. A chi-square goodness-of-fit test for a die gives p = 0.26. What is the conclusion at alpha = 0.05?

    A large p-value means the data are consistent with fairness. It does not prove fairness.
  4. 4. Which change increases the required sample size per group?

    n grows with the variance and shrinks with the square of the difference, so detecting smaller differences needs many more subjects.

Summary

  • Follow a fixed template: hypotheses, test and conditions, statistic and p-value, decision, conclusion with an interval.
  • Choose the test by the data structure: one sample, two independent samples, paired, proportions, categories, three or more groups.
  • Intervals widen with confidence level and narrow with โˆšn.
  • p-values and confidence levels are statements about methods and data under a null, not about the probability that a hypothesis is true.

Next: Practice Set: Regression, Bayes and Simulation