9  Statistical inference

Descriptive statistics summarize the data we have. Statistical inference asks what that data can tell us about the larger population it came from. This chapter introduces the central idea, which is comparing an observed result against what chance alone would produce, and then applies that idea to three kinds of question: whether a single observed proportion is surprising, whether two groups really differ, and what range of values for a population quantity the data leaves plausible.

Everything in this chapter is built by simulation rather than by formula. Each technique comes down to repeating an experiment many thousands of times and asking how often chance alone produces a result as extreme as the one we actually observed, so the loops and functions from Chapter 8 are the only machinery we need.

9.1 Populations and samples

9.2 Sampling distributions through simulation

9.3 Hypothesis testing

9.3.1 The logic of a hypothesis test

9.3.2 A complete example: testing a single proportion

9.3.3 Comparing two proportions

9.3.4 Comparing two means

9.3.5 Testing a correlation

9.3.6 One-sided and two-sided tests

9.4 Confidence intervals

9.4.1 From tests to intervals

9.4.2 Constructing and interpreting an interval

9.5 Summary

9.6 Exercises