Read the observationsLesson 13 of 30 · 6 min
Your sample is not the whole world
Identify how a sampling procedure changes the population a result describes.
The population is the collection you want to describe. A sample is the subset observed. Selection bias occurs when the selection procedure systematically changes which members are represented in a way relevant to the question.
Suppose the question concerns all requests, including slower mobile clients. A test drawn only from desktop clients can estimate desktop performance precisely while answering the wrong question. More desktop requests do not fill in the missing mobile clients.
The constructed population below has two groups with different elapsed times. Compare a convenience sample containing only the first group with a simple random sample from everyone. The random sample still has sampling error; it does not exactly reproduce the population mean on every draw.
- Desktop
- Mobile
Which sample can reveal that the slower group exists?
Write a prediction (optional)
Run the prepared example
This page puts the example in the Python editor. Select Run Python with the code unchanged.
Constructed population
A saved draft is open. To run the published example, open Editor tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
What to compare
Compare Population mean (ms), Desktop-only sample mean (ms) and Random sample mean (ms). Compare the mobile counts for the two samples. Which procedure includes mobile requests?
Your result
Result tools
Every desktop request in the model takes 40 ms. The population mean is 60 ms because the full population also includes mobile requests at 140 ms.
Published example output
The site ran the original code to produce this reference. Build environment ↗
Population mean (ms): 60.0 Desktop-only sample size: 100 Desktop-only sample mean (ms): 40.0 Mobile requests in desktop-only sample: 0 Random sample mean (ms): 66.0 Slow-group observations in random sample: 26
Every desktop request in the model takes 40 ms. The population mean is 60 ms because the full population also includes mobile requests at 140 ms.
Change and run again
In the Python editor, replace convenience = population[:100] with convenience = population[:500]. Select Run Python again. Find Desktop-only sample size, then compare Mobile requests in desktop-only sample and Desktop-only sample mean (ms) with the first run. Has the larger sample reached mobile requests? Return to the Python editor
What this example supports. The population is constructed with fixed group values. Real sampling needs a defined frame, nonresponse accounting and a defensible route to the target population.
Try a fresh case
A survey of museum visitors asks whether the whole town likes museums. What is the main concern?
Hints for this question
- Find who has no chance of appearing.
- Ask whether being sampled is related to the outcome.