Basic Statistics for Data Science
Data Science Fundamentals
Chapter 6 · Basic Statistics for Data Science
ds1-4 used quartiles and an IQR without fully explaining either, promising this chapter would. This is that chapter — and everything here is deliberately vocabulary-first: ds1-7 through ds1-9 all lean on the terms defined below without redefining them.
Mean, Median & Mode — And Why the Choice Matters
Mean is the familiar average — sum divided by count. Median is the middle value once everything is sorted. Mode is the most frequent value. They usually sit close together — until a dataset has extreme values, at which point they diverge in a way that actually matters.
ds1-4's own exercise raised a large, genuine catering order — statistically an outlier, but a real sale. That single order pulls the mean order size noticeably upward, even though most individual orders are much smaller — the mean is sensitive to extreme values because every value, including the largest, contributes to the sum. The median order size barely moves at all, because it only cares about which value sits in the middle position, not how large the largest one is. Neither statistic is "wrong" — a mean is the right choice for projecting total expected revenue; a median is the right choice for describing what a "typical" order actually looks like. Reporting only one of the two, without saying which, is a common way real analysis becomes quietly misleading.
Spread — Delivering on ds1-4's Own IQR Promise
Range is simply max minus min — the crudest measure of spread, and highly sensitive to a single extreme value. Variance is the average of each value's squared distance from the mean; standard deviation is variance's own square root, put back into the original units so it's directly interpretable.
Quartiles split sorted data into four equal-sized groups: Q1 (the 25th percentile) is the value below which a quarter of the data falls; Q2 is the median itself; Q3 (the 75th percentile) is the value below which three-quarters of the data falls. IQR (interquartile range) is simply Q3 − Q1 — the spread of the middle half of the data, deliberately ignoring the most extreme quarter on each end. ds1-4's own 1.5×IQR threshold is a long-standing statistical convention (originating with the box plot itself) for marking a value as unusually far outside that middle-half range — not an arbitrary number, but not a law of nature either, just a widely agreed default.
ds1-8's own box-plot section will look like a picture of exactly the numbers defined here, not new material.
Distributions & the Normal Curve
A distribution describes the overall shape of how values are spread across their possible range — not any single number, but the whole pattern. The normal distribution (the familiar symmetric "bell curve") is the single most important reference shape in statistics, fully described by just two numbers: its mean (the center) and its standard deviation (how wide the bell is). The empirical rule gives a fast, useful approximation for normally distributed data: roughly 68% of values fall within one standard deviation of the mean, roughly 95% within two, and roughly 99.7% within three.
Correlation vs. Causation
Correlation measures how strongly two variables move together, typically as a number from −1 to 1 (Pearson's correlation coefficient): 1 means they move in perfect lockstep upward together, −1 means one rises exactly as the other falls, 0 means no linear relationship at all. ds1-7's own scatter plots are the standard way to actually see a correlation visually.
Probability — Just Enough, Not a Full Course
A probability is a number from 0 to 1 describing how likely an event is. Two events are independent if one happening tells you nothing about whether the other happens (two separate coin flips); they're dependent otherwise (drawing two cards from the same deck without replacement — the first draw changes what's left for the second). This is deliberately the full extent of probability covered here — enough vocabulary to understand later statistical statements, not a dedicated probability course.
Sampling
A population is every member of the group actually being studied; a sample is the subset actually measured, because measuring an entire population is usually impossible or impractical. A sample is only useful if it's representative — if it resembles the population in the ways that matter for the question being asked.
ds1-1's own retail example: if a data scientist only sampled weekday transactions when investigating a weekend sales dip, the sample would be structurally incapable of ever revealing the pattern being investigated — not because of a calculation error, but because the sample itself excludes exactly the data the question depends on. This is sampling bias: a flawed sampling method producing a misleading conclusion even when every individual calculation performed on it is done correctly.
Hands-On Exercises
Using this chapter's own catering-order example, explain why reporting only the mean order size (without the median) could be misleading, and identify which of the two statistics is the right choice for projecting total expected revenue.
📄 View solutionExplain, using this chapter's own definitions, what IQR actually measures and why the 1.5×IQR threshold from ds1-4 is described here as "a widely agreed default," not an arbitrary number or a law of nature.
📄 View solutionUsing this chapter's own ice-cream/drowning example and its own weekday-sampling example, explain the difference between a confounding-variable problem and a sampling-bias problem — are they the same kind of mistake?
📄 View solutionChapter 6 Quick Reference
- Mean — sensitive to outliers · Median — robust to them · Mode — most frequent value
- Q1/Q2(median)/Q3 split sorted data into quarters; IQR = Q3 − Q1; 1.5×IQR is a box-plot convention, delivering ds1-4's own deferred promise
- Distribution — the overall shape of spread; the normal curve and the 68-95-99.7 empirical rule
- Correlation (−1 to 1) never proves causation alone — watch for confounding variables
- Probability basics — independent vs. dependent events, deliberately scoped light
- Sampling — population vs. sample, and sampling bias as a structural flaw, not a calculation error
- Next chapter: Data Visualization I: Matplotlib Fundamentals