Statistics · Week 3 of 4 · 5–6 hours
Data Distributions and Correlation Analysis
See the shape of your data and measure how two variables move together.
Learning objectives
By the end of this week you will be able to:
- Build and read a histogram.
- Describe a distribution as symmetric, right-skewed or left-skewed.
- Apply the 68-95-99.7 rule to normally distributed data.
- Calculate and interpret a correlation coefficient and avoid the causation trap.
Lessons
Data Distributions
A distribution shows how often each value (or range of values) occurs. The standard picture is a histogram: the values are split into bins along the bottom, and the height of each bar is how many values fall in that bin. In Excel: Insert > Charts > Histogram.
Common shapes:
- Symmetric: the left and right sides mirror each other; mean ≈ median.
- Right-skewed (positive skew): a long tail to the right, from a few large values. Incomes, order values and website time on page often look like this. Mean > median.
- Left-skewed: a long tail to the left. Scores on an easy test. Mean < median.
- Bimodal: two peaks, often a sign that two different groups are mixed together (for example weekday and weekend sales).
The normal distribution is the famous symmetric bell curve. Many measurements (heights, manufacturing errors) are roughly normal. Its handy property, the 68-95-99.7 rule:
- About 68% of values lie within 1 standard deviation of the mean.
- About 95% lie within 2 standard deviations.
- About 99.7% lie within 3 standard deviations.
Example: if packing times average 10 minutes with a standard deviation of 2, about 95% of orders are packed in 6 to 14 minutes. A 17-minute order is unusual and worth a look.
Correlation Analysis
Correlation measures how strongly two numeric variables move together in a straight-line pattern. The correlation coefficient r runs from −1 to +1:
| r | Meaning | Example |
|---|---|---|
| close to +1 | strong positive: as one rises, so does the other | ad spend and website visits |
| close to 0 | no straight-line relationship | shoe size and exam score |
| close to −1 | strong negative: as one rises, the other falls | price and units sold |
A rough guide: |r| above 0.7 is strong, 0.4 to 0.7 moderate, below 0.4 weak.
Always plot it first. Make a scatter plot (one variable on each axis). Correlation only measures straight-line patterns; a curved relationship or one outlier can make r misleading.
Excel: =CORREL(A2:A50, B2:B50). pandas: df["ad_spend"].corr(df["sales"]) or df.corr(numeric_only=True) for every pair.
Correlation is not causation. Ice cream sales and sunburns are strongly correlated, but ice cream does not cause sunburn; hot weather drives both. That hidden driver is called a confounding variable. Report correlations as "is associated with", not "causes", unless you have run a controlled experiment.
Watch
- VideoStatistics - A Full University Course on Data Science Basics (freeCodeCamp)
Optional: the chapters on distributions and correlation.
Practice
Use a dataset with at least two numeric columns (for example advertising spend and sales, or a free Kaggle dataset).
- Make a histogram of one column and describe its shape. Compare the mean and median.
- Make a scatter plot of the two columns and add a trendline.
- Calculate r with CORREL and describe it in words.
- Name one possible confounding variable.
Check your understanding
Try each question first, then open it to see the answer.
A histogram has a long tail to the right. Which is larger, the mean or the median?
The mean.
Test scores are normal with mean 70 and standard deviation 5. About what share of students scored between 60 and 80?
About 95% (within 2 standard deviations).
r = −0.85 between price and units sold. Describe it.
A strong negative relationship: higher prices are associated with fewer units sold.
Assignment
Submit your histogram, scatter plot, correlation value and a paragraph interpreting them, including the confounding variable.