Chapter 6 · Solutions
Practice Challenges, Worked Answers ✅
Full solutions to the four "Population vs. Sample" challenges. Try them yourself first, then compare.
Statistics, Data Science and AI: A Visual Handbook · John Fisher · 2026
⚙️ Setup¶
In [1]:
import numpy as np
import pandas as pd
rng = np.random.default_rng(60)
print("✅ Ready.")
✅ Ready.
CHALLENGE 1 · POPULATION vs SAMPLE
Identify each part
A university has 20,000 students. A researcher surveys 500 of them about study habits. Name the population, the sample, and the sample size n.
In [2]:
answer = {
"Population": "all 20,000 students at the university",
"Sample": "the 500 students who were surveyed",
"Sample size n": 500,
}
for k, v in answer.items():
print(f"{k:<15}: {v}")
Population : all 20,000 students at the university Sample : the 500 students who were surveyed Sample size n : 500
Answer: Population = the entire group of interest (20,000 students); sample = the subset actually measured (500); n = 500. We study the sample to learn about the population.
CHALLENGE 2 · PARAMETER or STATISTIC
Classify and give the symbol
Label each as a parameter or a statistic, and give its symbol: (a) the mean height of ALL NBA players; (b) the mean height of 30 sampled players; (c) the proportion of a 1,000-person poll who approve.
In [3]:
rows = pd.DataFrame({
"quantity":["mean height of ALL NBA players","mean height of 30 sampled players","approval in a 1,000-person poll"],
"type": ["Parameter","Statistic","Statistic"],
"symbol": ["μ (mu)","x̄ (x-bar)","p̂ (p-hat)"],
})
print(rows.to_string(index=False))
quantity type symbol mean height of ALL NBA players Parameter μ (mu) mean height of 30 sampled players Statistic x̄ (x-bar) approval in a 1,000-person poll Statistic p̂ (p-hat)
Answer: Anything describing the whole population is a parameter (Greek letters: μ, σ, p). Anything from a sample is a statistic (Latin: x̄, s, p̂). "All players" → parameter; "sampled / polled" → statistic.
CHALLENGE 3 · COMPUTE A STATISTIC
Estimate the parameter from a sample
A sample of 8 customers spent (in $): [12, 18, 9, 22, 15, 30, 11, 19]. Compute the sample mean x̄ and sample proportion p̂ who spent more than $15. What are these estimating?
In [4]:
spend = pd.Series([12, 18, 9, 22, 15, 30, 11, 19])
xbar = spend.mean()
phat = (spend > 15).mean()
print(f"Sample mean x̄ = ${xbar:.2f}")
print(f"Sample proportion p̂ = {phat:.2%} spent more than $15")
print("\nThese sample STATISTICS estimate the population PARAMETERS")
print("(μ = mean spend of ALL customers, p = proportion of ALL customers over $15).")
Sample mean x̄ = $17.00 Sample proportion p̂ = 50.00% spent more than $15 These sample STATISTICS estimate the population PARAMETERS (μ = mean spend of ALL customers, p = proportion of ALL customers over $15).
Answer: x̄ = $17.00, p̂ = 50%. They're our best estimates of the unknown population mean (μ) and proportion (p) of all customers.
CHALLENGE 4 · CENSUS or SAMPLING
Pick the right approach
For each, say whether a CENSUS or a SAMPLE is more appropriate, and why: (a) a national population count every 10 years; (b) testing whether a factory's light bulbs last 1,000 hours; (c) a quick exit poll on election night.
In [5]:
decisions = {
"National population count": "CENSUS — exact counts of everyone are legally/strategically required",
"Light-bulb lifetime test": "SAMPLE — testing is destructive; you can't burn out every bulb",
"Election-night exit poll": "SAMPLE — results are needed fast and cheaply, with a margin of error",
}
for k, v in decisions.items():
print(f"• {k}\n -> {v}\n")
• National population count
-> CENSUS — exact counts of everyone are legally/strategically required
• Light-bulb lifetime test
-> SAMPLE — testing is destructive; you can't burn out every bulb
• Election-night exit poll
-> SAMPLE — results are needed fast and cheaply, with a margin of error
Answer: Use a census when you truly need every individual (national count). Use a sample when a census is impossible (destructive testing), too slow, or too costly (exit polls), accepting a small, quantified margin of error.
🎉 Nicely done!
You separated population from sample, told parameters from statistics (and their symbols), computed estimates from a sample, and chose between a census and sampling, the foundation of all the inference chapters ahead.
Statistics, Data Science and AI: A Visual Handbook · © 2026 John Fisher