Population and sample#
- A population is everyone (or everything) you want to know about - all voters in Madhya Pradesh, all orders ever placed on an app.
- A sample is the part you actually measure - 2,000 voters, last week's 500 orders.
We compute statistics from the sample (x̄, s) to estimate parameters of the population (μ, σ).
| Population (parameter) | Sample (statistic) | |
|---|---|---|
| size | N | n |
| mean | μ | x̄ |
| standard deviation | σ | s |
| proportion | p | p̂ |
Sampling methods and bias#
| Method | How | Good for |
|---|---|---|
| simple random | everyone has an equal chance | the default |
| stratified | split into groups (e.g. city, gender), sample from each | making sure small groups are represented |
| cluster | pick whole groups (e.g. 20 random schools) | when a full list of people isn't available |
| systematic | every k-th item (every 10th invoice) | quality checks on a production line |
| convenience | whoever is easy to reach | quick pilots - often biased |
A huge biased sample is worse than a small random one. An online poll on a cricket website will never represent the views of all citizens, however many people vote.
Population पूरा समूह है (जैसे शहर के सारे लोग), sample उसका छोटा हिस्सा जिसे हम सच में नापते हैं। Sample random होना चाहिए - वरना नतीजा biased होगा। जैसे दाल पकी या नहीं, यह देखने के लिए पूरी हांडी नहीं खाते, पर चम्मच अच्छी तरह हिलाकर लेते हैं - वही random sample है।
Sample statistics in Python#
For a sample, NumPy's std needs ddof=1 (divide by n − 1); pandas uses n − 1 by default.
Sampling distributions#
Take many samples of the same size and compute the mean of each. Those means vary - their distribution is the sampling distribution of the mean. Its standard deviation is called the standard error (SE):
SE = σ ÷ √n (estimate it with s ÷ √n)
Bigger samples → smaller SE → more precise estimates. Because of the square root, 4× the data only halves the error.
The Central Limit Theorem (CLT)#
The CLT: if you take samples of size n from any population with mean μ and SD σ, then for large n (often n ≥ 30 is enough) the sample mean is approximately normal with mean μ and SD σ/√n - even if the population itself is skewed.
Delivery times are right-skewed (most are quick, a few are very late). Watch what happens to the averages:
With n = 5 the means are still a bit skewed; with n = 50 they form a clear bell curve centred on 30, with SD close to σ/√n.
The CLT is why we can build confidence intervals and run hypothesis tests on averages without knowing the population's exact shape - the next lesson.
Summary#
- Statistics (x̄, s, p̂) from samples estimate parameters (μ, σ, p) of populations.
- Random sampling avoids bias; convenience samples are often biased.
- Use
ddof=1for the sample SD in NumPy. - Standard error = σ/√n; bigger samples give more precise means.
- CLT: sample means are approximately normal for large n, whatever the population shape.