Correlation and Regression
Measuring how closely two quantities move together, and fitting the straight line that best predicts one from the other.
Needs a step first: 5
For paired data, the correlation coefficient , between and , measures how close the points lie to a straight line. The least-squares regression line has slope , passes through the point of means , and explains a share of the variation in . Correlation does not show cause, and the line should not be trusted far outside the data. It is the statistician's view of least squares and the start of linear regression in machine learning.
Where it shows up: Linear regression in machine learning is the same fit with many inputs at once, found by least squares or by gradient descent.
How to hold it: Give it to the machine, then check
Let software compute and the regression line; check that the line passes through , that the sign of its slope matches the scatter plot and that is believable before trusting any prediction.
What knowing it looks like
- Compute the correlation coefficient and the regression line by hand for a small data set.
- Interpret the slope, the intercept and in the context of the data.
- Give an example of a strong correlation without causation, and of a strong relationship that misses because it is not straight.
Test yourself
For the data , , , , , find the regression line of on and the correlation coefficient .
Show the worked answer
Needs a step first: 5
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Correlation and Regression" (Core tier): Measuring how closely two quantities move together, and fitting the straight line that best predicts one from the other. I already know: Random Variables, Expectation and Variance. Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away. Finish by testing me with this: For the data $(1,2)$, $(2,4)$, $(3,5)$, $(4,4)$, $(5,5)$, find the regression line of $y$ on $x$ and the correlation coefficient $r$. Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.
Needs first
Picks up from the children's map: Scatter Graphs and Correlation
Leads to
On the way to
Recommended
- MIT 6.1200J Mathematics for Computer ScienceMIT OpenCourseWare · CourseMIT's 2024 course on proofs, number theory, graphs, counting and discrete probability, with lecture videos, notes and problem sets.
- Mathematics for Machine LearningDeisenroth, Faisal and Ong (Cambridge University Press) · BookA free book that gathers exactly the linear algebra, vector calculus, probability and optimisation machine learning uses, then applies them to regression, PCA and classification.
- Seeing TheoryBrown University · InteractiveA visual introduction to probability and statistics in which you flip coins, draw samples and fit lines in the browser; complete and ad-free, with a Chinese version.
- Harvard Stat 110: ProbabilityJoe Blitzstein, Harvard University · CourseJoe Blitzstein's Harvard probability course: lecture videos, about 250 practice problems with solutions and a free online textbook, strong on intuition and story proofs.
- Information Theory, Inference, and Learning AlgorithmsDavid MacKay · BookMacKay's book connecting entropy, coding, Bayesian inference and neural networks, free to read online and still the one recommended for information theory with intuition.
- 宋浩老师官方宋浩(山东财经大学) · Videos · 中文Full university courses in calculus, linear algebra and probability by a Shandong University of Finance and Economics lecturer, clear and good-humoured; a new calculus series came out in October 2026.