The Line That Best Fits a Cloud of Points
Measurements never fall on a perfect line. Height and weight, study hours and test scores, temperature and ice-cream sales: the points scatter, yet a trend hides inside the cloud. The correlation coefficient r puts a single number on how tightly the points hug a straight line, and least squares draws the one line that makes the total squared vertical miss as small as possible. From that line we read a slope, ask how much of the scatter it explains through R squared, and finally test whether the slope is real or could be only noise. This is the same algebra as the engineering-math lesson on projection and least squares, seen through a different lens: there we projected a vector onto a column space, here we fit a line to noisy data and ask what it lets us infer.
Grab any point and drag it. The correlation coefficient r updates at once. When the points line up going up together, r sits near +1; when higher x tends to go with lower y, r heads toward -1; when the cloud is round and shapeless, r hovers near 0. r measures only linear association and nothing else: it does not care about the units, and it never leaves the range from -1 to +1.
For a fixed cloud, try to place a line yourself with the slope and intercept sliders. The meter tracks SSE, the sum of the squared vertical gaps between each point and your line. Push the line around and the meter climbs; there is exactly one slope and intercept that push it to the bottom. That lowest point is the least-squares fit, and the Snap button jumps you straight to it. Best fit means the smallest squared error, not a zero error.
Each residual is the leftover, the vertical gap of the real y minus the predicted y-hat. Squaring and adding them gives SSres, how much the line still misses. Compare that with SStot, the misses you would have using only the flat mean line. Their ratio gives R squared = 1 - SSres / SStot, the fraction of the up-and-down variation the line explains. Toggle between the mean baseline and the fitted line to watch the leftover shrink.
Start from a clean line and pour in noise. As the slider raises the scatter, the same underlying trend gets buried, and r slides down from near 1 toward 0. The relationship has not changed; our ability to see it has. Strong correlation is not about a steep slope, it is about how little the points stray from the line.
A slope measured from data is only an estimate, so we wrap it in a confidence interval. With few points or heavy noise the interval is wide and may straddle zero, which means the trend could be an accident. Collect more points and the interval tightens; once it clears zero entirely, we call the slope statistically significant. Slide the sample size and watch the interval close in on the true slope.