Study hours and test score, height and weight, ad spend and sales — plot the relationship between two such variables on a scatter plot, and you can see the pattern the points form. If the points cluster tightly along a line rising to the right, that's called "a strong positive correlation"; if they're scattered completely randomly, that's "no correlation." A single number between −1 and 1 that represents this degree of scatter (or clustering) is the correlation coefficient r.

The closer r is to 1, the more tightly the points hug a line rising to the right; the closer to −1, the more tightly they hug a line falling to the right. If r is close to 0, there's no clear linear relationship between the two variables. It's important to remember that r only measures the strength of a "linear relationship" — points can trace a perfect pattern along a curve and still give a low r.

r ≈ 0.95 r ≈ 0.1
Closer to a line (left) means a larger |r|; more scattered (right) means closer to 0

Once you've confirmed there's a correlation, the next question is "how do I draw a single line that represents that relationship?" No line can possibly pass through every single point, so you have to choose the line that fits best. The most widely used standard for this is the least squares method — finding the line that minimizes the sum of the squared vertical distances (residuals) from each point to the line, called the SSE. The reason for squaring is the same as when finding standard deviation: to keep positive and negative residuals from canceling out. The line found this way is called the regression line.

There's something crucial to remember here: having a correlation doesn't mean there's a cause-and-effect relationship (causation). A famous example: "ice cream sales" and "the number of swimming accidents" have a fairly high correlation coefficient. Does that mean ice cream causes accidents? No — the real cause behind both is simply "hot weather." On hot days, ice cream sells more and swimming increases, so accidents increase too; the two variables aren't directly causing each other. This is called a "hidden third variable," and it's important to build the habit of asking, whenever you see a correlation, "could there be another cause hiding behind this?"

On our activity page, you can use a slider to change how scattered the points are and watch how the actual calculated correlation coefficient changes, then fit a line to study-hours-vs-test-score data yourself and use the SSE value to see how close you get to the "correct line" found by the least squares method.