C.W.K.
Stream
Lesson 02 of 05 · published

Population vs Sample: The Glimpse Problem

~8 min · population, sample, estimation

Level 0Math Novice
0 XP0/59 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

What You Want vs What You Can See

The population is the complete universe of all possible data — every word ever spoken, every photo ever taken, every customer who could ever exist. You can never observe the whole population. The complete set is too big, too distributed, often partly in the future.

The sample is what you actually observe — a finite subset. Your training dataset. A poll of 1,000 voters. Last quarter's customer behavior. Your goal as a statistician (or ML engineer) is to use the sample to infer something true about the population.

Sample → Population Bridge

The whole game of statistics is figuring out how much you can trust an inference from sample to population. A bigger sample buys you more confidence; a biased sample buys you wrong answers no matter how big.

In ML: training data is a sample. The deployed model has to generalize to a population that includes inputs it never saw. The closer your sample resembles the population, the better the model generalizes. Data quality is sample quality.

Population is the truth. Sample is what you have. The art of ML is making the leap responsibly — and knowing the leap is always a bet.

Code

Estimation as sample size grows·python
import numpy as np

# True population mean (which you don't know in real life)
population = np.random.normal(loc=100, scale=15, size=1_000_000)
true_mean = population.mean()
print(f"true mean: {true_mean:.3f}")

# Take a sample of 30 — what do we estimate?
sample = np.random.choice(population, size=30)
print(f"sample mean (n=30): {sample.mean():.3f}")

# Take a bigger sample
sample = np.random.choice(population, size=10_000)
print(f"sample mean (n=10000): {sample.mean():.3f}")
# Bigger samples → estimates converge to the truth

External links

Exercise

Generate a population of 1,000,000 random numbers. Take samples of size 10, 100, 1000, 10000. For each, compute the sample mean. Plot or print all four. Notice how the sample mean wobbles for tiny samples and stabilizes for big ones.
Hint
np.random.choice(population, size=n) gives you a sample. Bigger n → estimate closer to the true mean — that's the law of large numbers showing up.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 2

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.
  1. Happycurio3
    Happycurio3

    엄청나게 큰 국 솥(population)에서 숟가락(np.random.choice)으로 딱 10방울(size=10)만 떠본다. 로봇은 작은 표본만 맛보고도 솥 전체의 염도를 맞히는 연습을 하는 중이다. 10방울보다는 한 국자가 더 정확하하다. 로봇은 데이터가 많아질수록 모집단의 진실에 다가간다. 헐! (로봇은 양질의 많은 데이터에 집착한다.)

    💛 by Ttoriwarm
    1. Pippa
      Pippa· playfulHappycurio3Happycurio3

      숟가락 10방울 비유 좋아요. 핵심 catch 가 국을 잘 휘저었느냐 예요 — 표본이 한쪽으로 쏠려있으면 (한 곳에서만 떠내면) population 의 진짜 염도가 아니라 그 부근 염도만 맞히게 되거든요. AI 의 데이터 편향 (bias) 문제가 사실 이 휘젓기 부족 이고요. np.random.choice 가 균등하게 흩뿌려진 sample 을 뽑아주는 정신도 같은 결이에요. 작은 표본만 맛보고도 전체 염도를 맞힌다 는 그 자신감이 통계학과 AI 모형 학습의 공통 뿌리예요.

      💛 by Ttoriwarm