Module 7 · Statistics: Describing and Deciding · Lesson 23 of 51

Distributions, z-scores and correlation

The normal curve and the 68–95–99.7 rule, skew and log transforms, correlation (Pearson and Spearman), and why correlation is not causation.

In this lesson · about 40 minutes

  • Use the 68–95–99.7 rule on bell-shaped data
  • Compute and interpret a correlation coefficient
  • Spot confounders and Simpson's paradox

Whiteboard · watch and try

The normal curve and the 68–95–99.7 rule

5 steps
Press Play and the tutor will talk you through it while writing on the board. Pause any time to write on the board yourself.

Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.

Skew

Right-skewed data has a long tail of big values (spend, income, time on site): mean > median. A log transform (np.log1p(x)) often makes it bell-shaped, which helps many models. Left skew is the mirror image (e.g. exam scores near a maximum).

Correlation

Pearson's r measures straight-line association: +1 perfect rise together, −1 perfect opposite, 0 no straight-line relationship. Roughly: |r| < 0.3 weak, 0.3–0.7 moderate, > 0.7 strong. Spearman's version works on ranks, so it handles curves (as long as they only go one way) and outliers better. In pandas: df["a"].corr(df["b"]), df.corr(method="spearman").

Correlation misses curved relationships (r can be 0 for a perfect U-shape): always plot first.

Correlation is not causation

Three reasons two things move together without one causing the other: a confounder drives both; reverse causation (busy cafés hire more staff; staff don't cause busyness); or pure chance, especially when you test many pairs. To show causation you need an experiment (Module 9) or careful causal methods.

Simpson's paradox

A trend inside every group can vanish or flip when the groups are pooled. In the café data, weekends are better at three branches and much worse Downtown (office workers stay home). Pooled together, weekends look like they barely matter. Always check the relationship within groups.

Correlations, and the weekend paradox

Exercise

Which factor moves sales most?

For campus (Campus rows only), set r_temp to the Pearson correlation between temp_c and sales, and r_rain to the correlation between rain_mm and sales, both rounded to 3 decimals. Then set stronger to "temp_c" or "rain_mm", whichever has the larger absolute correlation (compute it, don't type it).

Code that runs before yours
import pandas as pd
import numpy as np
daily = pd.read_csv("kc_daily.csv", parse_dates=["date"])
campus = daily[daily["branch"] == "Campus"]

Check your understanding0 of 3 correct

Question 1

1.Branches with more staff have higher sales. Most likely explanation?

Question 2

2.r = 0 between x and y means…

Question 3

3.Within every branch weekends are better, yet pooled they look worse. This is…

Quiz score: 0 of 3

Exercises solved: 0 of 1

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. Kettle & Crumb and all its data are made up for teaching; any resemblance to a real business is a coincidence. Python runs in your browser with Pyodide, so results can differ slightly from your own computer. Power BI, Tableau and other product names belong to their owners. Read-aloud uses your device's built-in voices.