Skip to content
tezvyn:
Menu

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

Source: Wikipedia: Q-Q plotMediumHow cards are made

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.

Interview question

What is the primary purpose of using a Q-Q plot?

  • a.To calculate the p-value for a dataset's normality.
  • b.To assess if a dataset's distribution aligns with a theoretical distribution.Correct
  • c.To identify the optimal number of bins for a histogram.
  • d.To determine the correlation coefficient between two variables.
Why?

The card states that a Q-Q plot "visually checks if your data fits a theoretical distribution." It compares the quantiles of your data to those of a theoretical distribution. While it helps assess distribution fit, it is a visual diagnostic and does not provide a p-value, which is obtained from formal statistical tests.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on statistics — each one lists the topics its interview covers.

See open roles