beginnerstatistics

Sampling & Bias

Your data is only as good as how you collected it.

Key Points

What it is

Sampling is the process of selecting a smaller group from a larger population to study. Since you usually can't collect data from everyone or everything, you collect from a sample and use it to draw conclusions about the whole. Bias happens when that sample doesn't fairly represent the population — leading to conclusions that sound valid but are systematically wrong.

Why it exists

Collecting data from an entire population is usually impossible — too expensive, too slow, or just impractical. Sampling lets you study a manageable piece of the whole. But if that piece is selected carelessly, everything built on it — models, reports, decisions — inherits the flaw. Understanding bias is what separates a data scientist who produces reliable insights from one who produces confident nonsense.

What it measures

Sampling tells you how representative your data is of the real world. Bias measures the gap between your sample and the population it's supposed to represent — and whether that gap is random (acceptable) or systematic (dangerous).

Intuition

A restaurant wants to know if customers are happy. They survey people as they leave on a Friday night. The results are glowing. But they missed: people who left early because of bad service, people who never came back after a bad experience, and weekday regulars who have a completely different experience. The sample felt legitimate — they asked real customers — but it only captured the happiest, most recent slice. The bias was baked into the method, not the math.

Example

A model is trained to predict loan defaults using historical data from a bank. The historical data only includes people who were approved for loans. People who were rejected never appear in the dataset.

The model has never seen examples of the kinds of people most likely to default — because they were never given loans to default on. This is called survivorship bias. The model will seem accurate on historical data but may fail badly on new applicants who resemble the rejected group.

When to use

When not to use

Common mistakes

Notes

In practice

Bias in training data is one of the most common and consequential problems in real ML projects. Train/test splits must be done carefully to avoid data leakage — a form of sampling bias where future information sneaks into the training set. Feature engineering can accidentally introduce bias. Evaluating a model only on the kind of data it was trained on gives an inflated picture of how it will perform in the real world.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

central-limit-theoremhypothesis-testingprobability-basicsmean-median-mode
Chirp at me!