Courses / Computer Science XI (HSSC-I) – FBISE Complete SLO-Based Course
4.2 Experimental Design: Correlation vs Causation, Population and Sample
Unit 4 – Data and Analysis · 70 min read · 11 MCQs to check yourself
Correlation vs causation – a simple explanation with examples
1. Correlation vs causation
- Correlation: two variables change together.
- Causation: a change in one variable directly produces a change in the other.
Correlation does not imply causation. The relationship may be due to:
Reason Example A confounding (hidden third) variable Ice-cream sales and drowning both rise in summer – the cause of both is hot weather Reverse causation Hospitals have many sick people – hospitals do not cause sickness Pure coincidence Number of films an actor makes per year vs number of people falling into pools
How do we prove causation? With a randomised controlled experiment: randomly split subjects into a treatment group and a control group, change only one factor, and compare results. Randomisation balances hidden variables between the groups.
2. Experiments in data science
| Term | Meaning |
|---|---|
| Hypothesis | A testable statement: "a red Buy button increases sales" |
| Independent variable | What the experimenter changes (button colour) |
| Dependent variable | What is measured (purchases) |
| Control group | Gets the usual version (no change) |
| Treatment group | Gets the new version |
| Random assignment | Each subject has an equal chance to be in either group |
| Measures | Conversion rate, click-through rate, mean watch time, difference between groups |
Real-world experimentation – A/B testing:
- YouTube shows two thumbnails of the same video to different random viewers and keeps the one with the higher click-through rate.
- Facebook/Instagram test new feed designs on a small random group of users before releasing them.
- Online retail (Daraz, Amazon) compare two product-page layouts and measure purchases; they also test discounts and delivery-fee messages.
- Agriculture: two plots of wheat, one with new fertiliser, one without – compare yield.
- Medicine: clinical trials compare a new medicine with a placebo.
3. Data collection methods
| Method | How | Strength | Weakness |
|---|---|---|---|
| Designed experiment | Researcher controls conditions and randomly assigns treatments | Can show cause and effect | Costly; sometimes unethical or impossible |
| Observational study | Observe and record without interfering | Natural behaviour; cheaper | Shows association only; confounding variables |
| Survey / questionnaire | Ask a sample of people questions (Google Forms) | Fast, cheap, large reach | Biased or dishonest answers; low response rate |
| Census | Collect data from every member of the population (Pakistan's population census) | Complete, accurate | Very expensive and slow |
4. Population and sample; parameter and statistic
| Population | Sample |
|---|---|
| The whole group we want to know about | A part of the population actually studied |
| e.g. all HSSC-I students in Islamabad | e.g. 300 randomly selected HSSC-I students |
| Studying it is costly or impossible | Cheaper, quicker, practical |
| Parameter | Statistic |
|---|---|
| A number describing the population | A number describing a sample |
| Usually unknown | Calculated from data, used to estimate the parameter |
| Symbols: μ (mean), σ (standard deviation), N | Symbols: x (mean), s, n |
| e.g. average height of all students | e.g. average height of the 300 sampled students |
Statistics is the process of making inferences about population parameters from a random sample. A sample must be representative: use random sampling (every member has an equal chance), large enough size, and avoid sampling bias (e.g. surveying only your own friends, or online-only surveys that miss people without internet).
Random sampling in Python:
import random
random.seed(7)
students = list(range(1, 101)) # roll numbers of the population
sample = random.sample(students, 5) # simple random sample of 5
print(sample)
Output:
[42, 20, 51, 84, 7]
5. Choosing the right measure
| Situation | Best measure of centre | Why |
|---|---|---|
| Symmetric data, no outliers (heights) | Mean | Uses all values |
| Skewed data or outliers (salaries, house prices) | Median | Not affected by extreme values |
| Categories (favourite colour, shoe size sold most) | Mode | Only measure for non-numeric data |
| Spread measure | Use |
|---|---|
| Range | Quick idea; affected by outliers |
| IQR (interquartile range) | Spread of the middle 50%; robust to outliers – pairs with the median |
| Standard deviation | Average distance from the mean – pairs with the mean |
Example: salaries Rs 40k, 45k, 50k, 55k and 1 000k – mean = 238k (misleading), median = 50k (typical).
Special data structures (advanced): a census (whole population), a survey (sample answers questions), an observational study (watching without control) and a randomised experiment (controlled, random groups) – only the last can establish causation.
Correlation vs causation explained by Dr Nic with examples
Short and long questions
1. What is the difference between correlation and causation? Illustrate with an example.
Model answer
Correlation means two variables change together; causation means a change in one directly produces a change in the other. Correlation alone does not prove causation. Example: ice-cream sales and drowning incidents are positively correlated, but ice-cream does not cause drowning – both increase because of a confounding variable, hot weather (more swimming and more ice-cream).
2. Compare population and sample, and parameter and statistic.
Model answer
Population: the entire group of interest (all HSSC-I students in Pakistan). Sample: a subset actually studied (500 randomly chosen students). Parameter: a numerical value describing the population (true mean height μ) – usually unknown. Statistic: a value calculated from the sample (sample mean x̄) used to estimate the parameter.
3. Why are experiments important in data science? Give a real-world example.
Model answer
Experiments with random assignment to treatment and control groups are the only reliable way to show that one factor causes a change, separating causation from mere correlation. Example: an online shop (Daraz) shows design A of a product page to half its visitors and design B to the other half at random; if B gets significantly more purchases, the design change caused the increase (A/B testing). YouTube does the same with thumbnails.
4. Differentiate between an observational study and a designed experiment.
Model answer
In an observational study the researcher only observes and records data without influencing subjects (e.g. recording students' screen time and marks) – it can show association only. In a designed experiment the researcher deliberately changes one variable and randomly assigns subjects to groups (e.g. one group uses a study app, another doesn't) – it can show cause and effect.
5. When is the median more appropriate than the mean? Give an example.
Model answer
When data is skewed or has outliers, because the median is not pulled by extreme values. Example: monthly incomes Rs 40k, 45k, 50k, 55k, 1 000k – mean = 238k, which no one earns, while the median 50k represents a typical income.
6. What are data collection methods? Contrast any two data collection methods with respect to strength, weakness, reliability, cost and validity. (1 + 5)
Model answer
Data collection methods are the systematic ways of gathering information to answer a research question – designed experiments, observational studies, surveys/questionnaires, interviews, census and existing records.
| Basis | Survey (questionnaire) | Designed experiment |
|---|---|---|
| Strength | Collects data from many people quickly; can measure opinions | Can establish cause and effect by controlling variables |
| Weakness | Respondents may lie, misunderstand or not reply; sampling bias | Artificial setting; some experiments are unethical or impractical |
| Reliability | Moderate – depends on question design and sample size | High – conditions controlled and repeatable |
| Cost | Low (online forms are free) | High – materials, time and supervision |
| Validity | Lower – self-reported answers may not match real behaviour | High internal validity due to randomisation and control |
| (Observational studies: natural behaviour, low cost, but cannot prove causation; census: complete but very expensive.) |
7. Explain experimental design in data science. Describe the terms hypothesis, control group, treatment group and random assignment, and design a simple experiment for your college.
Model answer
Experimental design is planning how to collect data so that the effect of one factor can be measured fairly while other factors are controlled.
- Hypothesis: a testable prediction, e.g. "students who take daily online quizzes score higher".
- Treatment group: receives the change (daily quizzes).
- Control group: continues as normal (no quizzes) for comparison.
- Random assignment: students are placed in groups by chance so hidden factors (ability, interest) are balanced.
- Measure: the dependent variable – average test marks after four weeks; compare means. College experiment: randomly divide 60 XI students into two groups of 30; one group uses PrepOasis daily quizzes for four weeks; both take the same test; if the treatment group's mean is clearly higher, the quizzes are likely to cause the improvement. Ethical considerations: let the control group use the quizzes after the study.
This lesson ends with a quiz of 11 MCQs. Open the lesson on PrepOasis to take it and save your progress.
Previous: 4.1 Statistical Models: Correlation, Linear Regression, K-means and Smoothing · Next: 4.3 Summary Statistics and Data Visuals
All lessons in Computer Science XI (HSSC-I) – FBISE Complete SLO-Based Course