Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1 — Sampling Techniques

Lesson 9 of 46 in the free Introduction to Data Analytics notes on Siksha Sarovar, written by Rohit Jangra.

Sampling Techniques

Sampling is the process of selecting a subset (sample) from a larger group (population) so that conclusions drawn from the sample can be generalised to the population.

Key Terminology

TermMeaning
Population (N)The complete set of all items/individuals of interest
Sample (n)The subset actually observed
Sampling frameThe accessible list from which the sample is drawn (e.g. the college's student register)
Sampling unitA single element that can be selected
ParameterA numerical property of the population (μ, σ)
StatisticThe corresponding property computed from the sample (x̄, s)
Sampling errorThe difference between statistic and parameter due to chance
BiasSystematic error that does not shrink with sample size

Why Sample at All?

  1. Cost — surveying 1.4 billion people is impossible; 5,000 well-chosen people is not.
  2. Time — results are needed before they become irrelevant.
  3. Feasibility — destructive testing (crash tests, food-quality tests) rules out testing everything.
  4. Accuracy — a small, well-controlled sample often beats a huge sloppy census, because effort per unit is higher.

A. Probability (Random) Sampling

Every member has a known, non-zero probability of selection — this is what makes statistical inference (Unit 2) valid.

1. Simple Random Sampling (SRS)

Every unit has an equal chance of being selected; selection is by lottery or random number generator.

  • With replacement — a selected unit returns to the pool and can be picked again
  • Without replacement — more common in practice
AdvantagesDisadvantages
Unbiased; simplest to understandNeeds a complete sampling frame
Easy to compute sampling errorMay miss small subgroups entirely
No researcher influenceExpensive if the population is geographically spread
import pandas as pd
import numpy as np

np.random.seed(42)
population = pd.DataFrame({
    "student_id": range(1, 101),
    "marks": np.random.randint(35, 100, 100),
    "section": np.random.choice(["A", "B", "C"], 100, p=[0.5, 0.3, 0.2]),
})

# Simple random sample of 10 students
srs = population.sample(n=10, random_state=1)
print(srs["marks"].mean(), "vs population", round(population["marks"].mean(), 2))

2. Systematic Sampling

Select every k-th unit after a random start, where k = N / n is the sampling interval.

N = 1000 students, n = 100 needed
k = 1000 / 100 = 10
Random start r between 1 and 10, say r = 7
Selected: 7, 17, 27, 37, 47, ... , 997
AdvantagesDisadvantages
Simple and quick to executeDangerous if the list has a periodic pattern matching k
Spreads the sample evenly over the frameNeeds to know N in advance
Periodicity trap: if a list of houses repeats "corner house every 10th" and k = 10, every sampled house is a corner house — a systematically biased sample.
k = len(population) // 10
start = np.random.randint(0, k)
systematic = population.iloc[start::k]
print(len(systematic), "students selected, every", k, "th")

3. Stratified Sampling

Divide the population into homogeneous, non-overlapping strata (e.g. by gender, section, income band), then randomly sample within each stratum.

  • Proportionate — each stratum contributes in proportion to its share of the population
  • Disproportionate — small but important strata are over-sampled
AdvantagesDisadvantages
Guarantees representation of every subgroupRequires prior knowledge of strata membership
Lower sampling error than SRS for the same nMore complex to organise and analyse
Allows comparison between strataWrong stratification variable adds no benefit
# Proportionate stratified sample: 20% from each section
stratified = (population
              .groupby("section", group_keys=False)
              .apply(lambda g: g.sample(frac=0.2, random_state=1)))
print(stratified["section"].value_counts())
# A    10
# B     6
# C     4     -> proportions preserved

4. Cluster Sampling

Divide the population into naturally occurring clusters (villages, colleges, city blocks), randomly select entire clusters, and survey everyone inside the chosen clusters.

AdvantagesDisadvantages
Cheapest for geographically dispersed populationsHighest sampling error of all probability methods
No complete list of individuals needed — only of clustersClusters may be internally homogeneous → less information

Stratified vs Cluster — The Classic Exam Question

BasisStratified SamplingCluster Sampling
Group compositionStrata are internally homogeneous, different from each otherClusters are internally heterogeneous, similar to each other
SelectionSample within every stratumSelect whole clusters, ignore the rest
PurposeIncrease precisionReduce cost
Groups usedAll strata usedOnly selected clusters used
ExampleSample 10 students from each of A, B, C sectionsRandomly pick 3 colleges, survey all their students

5. Multi-stage Sampling

Sampling applied in stages: e.g. randomly select states → within them districts → within them villages → within them households. Used in national surveys like the NSSO and the Census follow-up surveys.

B. Non-Probability Sampling

Selection probability is unknown; results cannot be statistically generalised, but these methods are cheap and useful for exploratory work.

TechniqueHow units are chosenTypical useMain risk
ConvenienceWhoever is easiest to reachQuick pilot studies, classroom surveysSevere selection bias
Judgemental / PurposiveExpert picks "typical" or "informative" unitsCase studies, expert panelsResearcher bias
QuotaFixed counts per category filled by convenienceMarket researchNon-random within quota
SnowballExisting participants refer new onesHidden/hard-to-reach populations (e.g. rare disease patients)Network bias — friends resemble friends

Sample Size — What Drives It

For estimating a population mean:

        n = (Z × σ / E)²

  Z = z-score for the confidence level (1.96 for 95%)
  σ = population standard deviation (estimated)
  E = margin of error you can tolerate

Example: σ = 15 marks, E = 2 marks, 95% confidence
        n = (1.96 × 15 / 2)² = (14.7)² ≈ 216 students

Larger samples reduce sampling error (proportional to 1/√n) — note the diminishing returns: quadrupling n only halves the error.

Sampling Bias — What to Watch For

BiasDescriptionExample
Selection biasSome groups systematically more likely to be chosenOnline-only survey excludes those without internet
Non-response biasNon-responders differ from respondersOnly satisfied customers bother to reply
Survivorship biasOnly "surviving" units observedAnalysing only companies still in business
UndercoverageSampling frame misses part of the populationVoter list missing recent migrants
Volunteer biasSelf-selected participants are unusualOnline polls on news sites

A well-drawn sample is the bridge between the data you have and the population you want to talk about — and every inferential technique in Unit 2 silently assumes that bridge is sound.