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.

See the reasoning
Population80%20%Desktop-only sample100%Random sample74%26%
Population80%20%Desktop-only sample100%Random sample74%26%
  • Desktop
  • Mobile
Constructed population: 800 desktop requests at 40 ms and 200 mobile requests at 140 ms. The seeded random sample includes 26 mobile requests out of 100; a larger desktop-only sample would still exclude that group.

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

Editor tools
About Python ↗

Ctrl+Enter or ⌘+Enter runs the code.

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?

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?

Choose an answer

Hints for this question
  1. Find who has no chance of appearing.
  2. Ask whether being sampled is related to the outcome.
Your notes