Skip to content

DS 104 · Module 2

From Samples to Judgment: Association, Uncertainty, and Limits

Extend Module 1's exploration skills to sample representativeness, the line between association and causation, intuition for uncertainty, and the gap between having evidence and having a result worth acting on.

Start Section 1
0 / 5 completed
Sync my progressJoin a session to keep progress across devices and share it with your instructor

Info

After you join, your completed lesson numbers are sent to your instructor together with your learner code, so they can see your progress. Use the codes your instructor gave you, and do not enter your name, company secrets or other personal data. Progress is kept with the rest of that session's data.

Learning objectives

  • Define target population; assess who is represented and who is missing
  • Interpret association without causal overreach; identify plausible confounders
  • Understand interval estimates conceptually; distinguish uncertainty from data quality
  • Separate evidence of difference from magnitude and decision relevance
  • Deliver a bounded exploratory report with findings, uncertainty, alternative explanations, and next questions

Population, Sample, and Bias

35 min

Population, Sample, and Sampling Bias

Learning objective: define target population; assess who is represented and who is missing.

The survey data in front of you was collected from respondents who chose to answer, and your manager wants to generalize the conclusion to "every student at the university." Before generalizing, the first question you must answer is: who does this sample actually represent, and who is missing from it? If the target population (all students) systematically differs from the people who ended up in the sample, the conclusion cannot simply be applied to the target population.

Population

  • The full group you actually want to understand and generalize a conclusion to
  • Example: every currently enrolled student at the university
  • You usually cannot collect data from every member

Sample

  • The subset of people you actually collected data from
  • In this dataset, one row (observation_id) is one sampled observation
  • Whether the sample represents the population depends on who was included, and how
Check whether the sample is balanced across strata
sample_share = df["sampling_stratum"].value_counts(normalize=True).round(3)
print(sample_share)

completion_by_stratum = df.groupby("sampling_stratum")["response_complete"].mean().round(3)
print(completion_by_stratum)
# A stratum whose sample share differs a lot from its known population share
# may be over- or under-represented in this sample
Common sources of sampling bias
SourceWhat it isRisk to the conclusion
Convenience samplingOnly collecting from whoever is easy to reach and willing to participateResults may represent only "people willing to participate," not the target population
Self-selectionRespondents decide for themselves whether to answer, often correlated with the outcome itselfPeople with strong opinions or a stake in the result are more likely to respond, skewing the overall distribution
Non-response biasPeople who were invited but never completed the survey differ systematically from those who didAnalyzing only completed responses may over- or understate the true picture
Doubling the sample did not shrink the bias (simulated scenario)

A survey distributed only through one voluntary online club collected 800 responses in round one, with Stratum B's share clearly below its known share among all students. The team decided to "send another round and double the sample"; after reaching 1600 responses, Stratum B's share barely moved, because the new responses still came from the same self-selected channel. The sample grew, but the sampling bias did not shrink at all.

  • Before generalizing to a target population, write down how that population is defined and how the sample was recruited or collected
  • Compare each stratum or group's share in the sample against its known or estimated share in the target population
  • Assuming a sample is representative just because it is large enough is one of the most common and most easily overlooked mistakes
  • Collecting more data through the same recruitment channel usually just makes the bias more stable, not smaller

Warning

A large sample size does not fix sampling bias: a thousand responses all collected through the same convenience channel can still systematically fail to represent the target population. Collecting more of the same kind of sample does not correct that bias.
Check yourself

A survey distributed through a student club that anyone can voluntarily join collects 800 responses. Before generalizing the conclusion to "every student at the university," what is the most important first step?

A survey distributed through a student club that anyone can voluntarily join collects 800 responses. Before generalizing the conclusion to "every student at the university," what is the most important first step?

Key takeaway: Completing the steps is not enough; the result must be verifiable, reproducible, and explainable.

Correlation and Causal Limits

35 min

Correlation, Confounding, and Causal Limits

Learning objective: interpret association without causal overreach; identify plausible confounders.

You find a clear positive correlation between exposure and outcome, and a colleague immediately says, "So increasing exposure raises outcome." Correlation only describes whether two variables move together; it cannot by itself prove that one causes the other. Before making a causal claim, you need to ask: could a third variable be driving both, making the observed association partly or entirely an illusion?

What a confounder looks like
ConditionWhat it means
Related to the explanatory variableThis third variable (e.g. age_band) is systematically associated with the distribution of exposure
Also related to the outcome variableThe same third variable (age_band) is also independently associated with outcome
Distorts the observed relationshipWithout accounting for this third variable, the association seen between exposure and outcome may be partly or entirely driven by age_band
Overall correlation vs. correlation within strata
overall_corr = df[["exposure", "outcome"]].corr().iloc[0, 1]
print(round(overall_corr, 3))

by_age = df.groupby("age_band").apply(lambda g: g["exposure"].corr(g["outcome"]))
print(by_age.round(3))
# If the overall correlation is strong but weakens or disappears within every age_band,
# age_band is likely a confounder rather than exposure truly causing outcome

Warning

A correlation shown on a scatter plot can never, by itself, prove causation. Even a strong correlation coefficient only says "exposure and outcome move together," not "exposure caused outcome," unless a more rigorous study design rules out confounders and other explanations.
  • When you see a strong correlation, first ask "is there a variable driving both of these," rather than jumping to a causal conclusion
  • Use known stratifying variables (such as age_band or group) to check whether the correlation still holds within subgroups
  • If the correlation disappears or weakens sharply within strata, the original overall correlation was likely influenced by a confounder
  • Causal claims require a more rigorous design than observational correlation; EDA is responsible for description and hypothesis generation, not causal proof
What a confounder was hiding (simulated scenario)

The overall data shows a correlation of 0.55 between exposure and outcome, and a colleague argues that "increasing exposure raises outcome." Checking by age_band, you find that older strata have both higher exposure and higher outcome, while younger strata have both lower; within each age_band, exposure and outcome are barely correlated. age_band drives both variables at once, producing an association that looks strong overall but does not exist within any single subgroup.

  1. Compute the overall correlation
    Calculate the overall correlation between exposure and outcome, and note its value and direction.
  2. List plausible confounders
    Think through which fields (such as age_band or group) could plausibly affect both variables at once.
  3. Recompute within strata
    Group by the plausible confounder and recompute the correlation within each group, comparing it to the overall figure.
  4. Adjust the wording to match
    If the correlation weakens or disappears within strata, replace causal language with "the overall association may be driven by another variable."
Check yourself

Overall, the correlation between exposure and outcome is 0.6, but computed separately within each age_band it drops close to 0. What is the most reasonable interpretation?

Overall, the correlation between exposure and outcome is 0.6, but computed separately within each age_band it drops close to 0. What is the most reasonable interpretation?

Key takeaway: Completing the steps is not enough; the result must be verifiable, reproducible, and explainable.

Estimation and Uncertainty

35 min

Estimation, Uncertainty, and Confidence-Interval Intuition

Learning objective: understand interval estimates conceptually; distinguish uncertainty from data quality.

You compute a sample mean outcome of 58.4 and report it as "the answer." But if you drew a fresh sample, that number would almost certainly come out a little different. A sample mean is an estimate of the true value in the target population, not an exact answer - and the point of an interval estimate is to honestly express how uncertain that estimate is.

Build intuition for interval estimates with resampling (bootstrap)
import numpy as np

rng = np.random.default_rng(seed=104)
values = df["outcome"].dropna().to_numpy()

boot_means = []
for _ in range(1000):
    resample = rng.choice(values, size=len(values), replace=True)
    boot_means.append(resample.mean())

boot_means = np.array(boot_means)
lower, upper = np.percentile(boot_means, [2.5, 97.5])
print(round(lower, 2), round(upper, 2))
# Roughly: if this sampling-and-estimation process were repeated many times,
# about 95% of the resulting mean estimates would fall in this range
What a wider interval most likely reflects
SituationEffect on interval widthSampling uncertainty, or a data quality problem?
Smaller sample sizeInterval usually widensSampling uncertainty: a smaller sample naturally estimates the population less precisely
Higher inherent variability in the data (larger standard deviation)Interval usually widensSampling uncertainty: reflects real-world spread, not necessarily an error in the data
A stratum with clearly inconsistent or systematically flawed measurementThe interval may widen, but the root problem is not samplingA data quality problem: fix the measurement or collection process first, rather than only growing the sample
The interval narrowed, but the center was wrong (simulated scenario)

A measurement tool used in one stratum has a systematic bias that underestimates every outcome value by about 5 points. Even if that stratum's sample size grows from 100 to 5000, the bootstrap interval narrows sharply, but its center remains wrongly low by about 5 points, because the problem is in the measurement, not the sampling. A larger sample makes you more confident in a wrong answer; it does not make the answer correct.

  • A narrow interval does not mean the estimate is correct; it only means resampling would produce consistent results
  • Before growing the sample size, confirm that the measurement method and data collection process have no systematic problem of their own
  • When different strata collect data in different ways, check their interval widths separately rather than relying on the pooled overall interval
  • When reporting an interval estimate, state clearly that it addresses sampling uncertainty only, not any other data quality issue

Warning

A larger sample size can narrow an interval estimate, but it cannot fix a systematic measurement error or a flawed sampling design. If the data carries a systematic bias, a larger sample only produces a narrower interval around a center that may still be wrong.
Check yourself

Two analyses both bootstrap an interval estimate for the mean outcome. Analysis 1 has a sample size of 50 and an interval of [50, 66]; Analysis 2 has a sample size of 2000 and an interval of [57, 59]. What is the most reasonable interpretation of this difference?

Two analyses both bootstrap an interval estimate for the mean outcome. Analysis 1 has a sample size of 50 and an interval of [50, 66]; Analysis 2 has a sample size of 2000 and an interval of [57, 59]. What is the most reasonable interpretation of this difference?

Key takeaway: Completing the steps is not enough; the result must be verifiable, reproducible, and explainable.

Statistical vs Practical Significance

30 min

Statistical vs Practical Significance

Learning objective: separate evidence of difference from magnitude and decision relevance.

Group A and Group B have mean outcomes of 60.2 and 60.5, and their 95% interval estimates do not overlap - meaning there is evidence the two groups genuinely differ. But the difference is only 0.3, and if the team's decision threshold is "a difference must reach 5 points before it is worth changing policy," this evidence-backed difference may not be worth acting on at all. "There is a difference" and "the difference is large enough to matter" are two separate questions.

Report both the evidence for a difference and its size
group_means = df.groupby("group")["outcome"].mean().round(2)
diff = round(group_means.loc["B"] - group_means.loc["A"], 2)
print("Mean difference:", diff)

decision_threshold = 5.0  # Defined in advance by the team: how large a difference is worth changing policy
print("Meets practical significance threshold:", abs(diff) >= decision_threshold)
Four combinations, four different next steps
Evidence a difference exists?Difference meets the practical threshold?Recommended next step
YesYesWorth planning action, and continue tracking whether the effect stays stable
YesNoThe difference is real but too small to justify committing resources to change the status quo
No(not applicable)Current evidence is insufficient to judge whether a difference exists; do not claim "no difference" - consider a larger sample or better measurement
Inconclusive (very wide interval)(not applicable)Uncertainty is too large to conclude anything; more data or more precise measurement is needed
"Evidence exists" leading to two different conclusions (simulated scenario)

Case one: Group A and B intervals do not overlap, the difference is 0.3 points, and the team's pre-defined threshold is 5 points; the conclusion is "evidence exists, but it is not worth acting on." Case two: in another comparison, Group A and B intervals also do not overlap, but the difference is 9 points, above the threshold; the conclusion is "evidence exists, and it is worth planning action." Both cases have the same strength of evidence (non-overlapping intervals), but the recommended next step differs completely because the size of the difference differs.

  • Define the "how large a difference is worth acting on" threshold with stakeholders before the analysis starts, not after the fact
  • Report "is there evidence" and "is the difference large enough" as two separate statements, not one blended conclusion
  • With a very large sample, even a tiny difference can show up as "evidence exists," which makes the threshold comparison even more important
  • If the interval is too wide to judge whether a difference exists, honestly report "insufficient evidence" rather than treating it as "no difference"

Warning

"There is evidence a difference exists" is not the same as "this difference is worth changing a decision over." When reporting any difference, state both whether there is evidence for it and its actual size, compared against a decision-relevant threshold defined in advance.
Check yourself

Two groups' interval estimates do not overlap, showing evidence of a difference, but the actual difference is only 0.3 points on a 0-100 scale. Which statement is most correct?

Two groups' interval estimates do not overlap, showing evidence of a difference, but the actual difference is only 0.3 points on a 0-100 scale. Which statement is most correct?

Key takeaway: Completing the steps is not enough; the result must be verifiable, reproducible, and explainable.

Independent Lab

45 min

Independent Lab: EDA Report

Learning objective: independently deliver a bounded exploratory report with findings, uncertainty, alternative explanations, and next questions.

Info

Lab task: using the practice data, independently choose a real question and work through this course's full loop - Question, Explore, Quantify Uncertainty, Compare, Challenge Explanations, Report Limits - to deliver a bounded EDA report. There is no published answer key; your reasoning and verification are what get reviewed.
  1. State a question
    Write down one concrete question this report will answer, and who would use the result.
  2. Explore the data
    Check distribution, spread, and missingness, and use the IQR rule to flag and investigate any suspicious observations.
  3. Quantify uncertainty
    Use resampling or a percentile method to build an interval estimate for your main estimate.
  4. Compare groups
    Compare at least two groups or strata, and check whether the comparison holds consistently across subgroups.
  5. Challenge your own explanation
    Identify at least one plausible confounder or sampling bias, and explain how it could change your conclusion.
  6. Assess practical significance
    Compare the size of the difference you observed against a decision threshold you define and justify yourself.
  7. Report limitations
    Write down what this analysis cannot yet answer, and what would need more data or a more rigorous design to confirm.
  • A clearly stated question and its intended audience
  • An exploration summary covering distribution, spread, missingness, and suspicious observations
  • An interval estimate for at least one main estimate, with its method explained
  • At least one challenge to an association or causal interpretation (confounder or sampling bias)
  • Evidence of a difference and practical relevance of that difference, stated as two separate points
  • At least one limitation and one follow-up question
  • A record of any AI assistance used and what you verified yourself
One report, two ways to write it up

Weak: "Group C's outcome is clearly higher, so we should prioritize resources there." Strong: "Group C's mean outcome is 8 points higher than the other groups, with a 95% interval estimate of [5, 11], above the team's 5-point action threshold; however, Group C also has higher exposure and a younger age_band mix, and both could be confounders that need to be ruled out before attributing the effect to Group C itself." The strong version reports the size of the difference, its uncertainty, and at least one alternative explanation still to rule out.

  • Reporting only the effect size and whether evidence exists, with no mention of plausible confounders or sampling bias
  • Hiding the multiple groupings tried during exploration and showing only the one that looks most supportive of the conclusion
  • Omitting what the analysis cannot answer, which makes the report sound more certain than the evidence actually supports
  • Not stating which steps AI helped produce and which parts were verified independently

Warning

If you try many different cuts of the data during exploration (different groupings, different field combinations) and report only the "prettiest" result, you risk multiple comparisons / cherry-picking: you may simply have found a pattern that noise happened to produce and mistaken it for a real finding. Report which cuts you actually checked, not just the most dramatic one.

Done

If AI helps compute statistics, draw charts, or draft the report text, check every item yourself: whether the data scope and grouping match your stated question, whether the calculations and assumptions are reasonable, whether the effect-size language is exaggerated, and whether any causal wording has overreached. AI can speed up drafting; verification and the final conclusion remain a human responsibility.

Key takeaway: Completing the steps is not enough; the result must be verifiable, reproducible, and explainable.

What next?