Statistics · easy

How do you check whether data is normally distributed, and when does it matter?

Asked in Data Analyst interviews, in the Statistics round.

Short answer

Look first: a histogram and a Q-Q plot show skew and tails better than any test. Shapiro Wilk and similar tests reject everything at large n. It matters for small-sample t-tests and regression inference, and much less for means at large n because of the CLT.

How to answer it

Definition

Two separate questions, and the second is the more important one. Checking is mostly visual; whether it matters depends entirely on what you are about to do.

How to check

import scipy.stats as st

st.probplot(x, plot=plt)        # Q-Q plot: the honest first look
x.hist(bins=50)                 # shape, modes, obvious skew
print(st.shapiro(x))            # formal test, useful only at small n
print(x.skew(), x.kurtosis())   # numbers to go with the picture

The Q-Q plot is the one to lead with. Points on the diagonal mean normal; curvature at the ends shows skew, and an S-shape shows heavy tails. It tells you HOW it departs, which a test's single p-value never does.

Why formal tests disappoint

Shapiro-Wilk and Kolmogorov-Smirnov test the null that the data is exactly normal. At n = 50 they miss real departures; at n = 100,000 they reject for deviations far too small to affect anything. The p-value ends up tracking your sample size rather than your problem, which is why the plot is the better tool.

When it matters

Barely at all      a t-test or a regression at a decent sample size, because
                   the CLT applies to the sample MEAN, not the raw data

Somewhat           small samples, under roughly 30, where the CLT has not
                   arrived yet

Quite a lot        anything about individual values rather than an average:
                   prediction intervals, control limits, quantile estimates

Not at all         tree models, which care about order rather than shape

Key points

FAQ

The 30-second answer

I would look at a Q-Q plot first, with a histogram beside it, because that shows how the data departs from normal rather than just whether it does. Formal tests like Shapiro-Wilk are dominated by sample size: on a big dataset they reject for deviations that make no practical difference.
The more useful half is when it matters. For a t-test or a regression at a reasonable sample size, hardly at all, because the central limit theorem applies to the sample mean rather than the raw values, and regression assumes normal residuals anyway rather than normal inputs.
Where it does matter is anything about individual observations rather than averages: prediction intervals, control limits, quantile estimates. There the skew changes the answer directly.

In the interview

Practice this for real