tezvyn:

Q-Q Plot: Visually Test if Data Fits a Distribution

AI-drafted, machine-checkedSource: Wikipedia: Q-Q plotintermediate
Q-Q Plot: Visually Test if Data Fits a Distribution

A Q-Q plot visually checks if your data fits a theoretical distribution (like normal). If the points form a straight line, it's a match. Use it to validate model assumptions.

WHY IT EXISTS Many statistical models assume data follows a specific distribution, like a normal (bell curve) distribution. While a histogram gives a rough idea of shape, it can be misleading depending on bin sizes. We need a more reliable way to visually check if our data's shape matches a theoretical one.

THE MENTAL MODEL Think of lining up two classes of students by height. If both classes have similar height distributions, the shortest student from class A will be about as tall as the shortest from B, the median from A matches the median from B, and so on. Plotting their heights against each other (A vs. B) would form a straight line. A Q-Q plot does this by comparing your data's quantiles to a theoretical distribution's quantiles.

HOW IT WORKS A Q-Q plot compares two probability distributions by plotting their quantiles against each other. To check if your data is normally distributed, the plot's y-coordinates are your data points, sorted, and the x-coordinates are the corresponding quantiles from a perfect normal distribution. If your data's distribution matches the normal distribution, the resulting points will form a rough y=x straight line.

WHEN TO USE IT Use a Q-Q plot to validate the assumptions of a statistical model before you trust its results. Its most common use is checking for normality. For example, you can check if the residuals (errors) of a linear regression model are normally distributed, which is a key assumption for the model's validity. It's generally more informative than a histogram for assessing normality.

WHEN NOT TO USE IT A Q-Q plot is a visual diagnostic, not a formal statistical test. For a definitive p-value on normality, use a test like Shapiro-Wilk. Q-Q plots can also be noisy and difficult to interpret with very small datasets. Don't rely on it as the sole proof of a distribution's shape.

ONE CANONICAL EXAMPLE You have a dataset of API latency measurements and want to see if they follow a normal distribution. You generate a Q-Q plot of your data against a theoretical normal distribution. If the points hug a straight line, your latencies are likely normal. If the points at the high end curve sharply upwards away from the line, it indicates your data has a 'heavy tail'—more extreme high-latency values than a normal distribution would predict.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.