📚 IB Maths: Regression Line Calculation and Interpolation Prediction | IB 数学:回归直线的求解与插值预测
In IB Mathematics, the least squares regression line is a core tool in statistics. It allows us to model the linear relationship between two variables and make predictions based on observed data. This article explains how to calculate the regression line by hand, how to interpret its components, and how to use it wisely for interpolation and extrapolation.
在 IB 数学课程中,最小二乘回归直线是统计部分的核心工具。它帮助我们建立两个变量之间的线性关系模型,并基于已知数据做出预测。本文将讲解如何手算回归直线、如何解读其组成部分,以及如何合理使用它进行内插和外推预测。
1. What is the Regression Line? | 什么是回归直线?
A regression line is a straight line that best summarises the trend in a scatter plot. For bivariate data, we often want to see how a response variable y changes with an explanatory variable x. The least squares regression line is the line that minimises the sum of the squared vertical distances between the data points and the line itself.
回归直线是一条能够最好概括散点图中变化趋势的直线。对于双变量数据,我们通常想知道响应变量 y 如何随着解释变量 x 变化。最小二乘回归直线就是使数据点到直线的垂直距离的平方和最小的那条直线。
2. The Equation of the Least Squares Regression Line | 最小二乘回归直线的方程
The equation is written as y = a + bx, where b is the slope and a is the intercept. Here, a is the value of y when x = 0, and b represents the average increase in y for each one-unit increase in x.
回归直线的方程写作 y = a + bx,其中 b 是斜率,a 是截距。截距 a 是 x = 0 时 y 的值,斜率 b 表示 x 每增加一个单位时 y 的平均变化量。
y = a + bx
3. Key Formulas: Sxx, Sxy and Syy | 关键公式:Sxx、Sxy 与 Syy
To find the least squares estimates of b and a, we first compute three sums of squares. Let n be the number of data points. The quantities Sxx, Sxy and Syy are defined as follows:
为了求 b 和 a 的最小二乘估计,我们需要先计算三个平方和。设 n 为数据点个数。Sxx、Sxy 和 Syy 的定义如下:
Sxx = Σx² − (Σx)² ⁄ n
Sxy = Σxy − (Σx)(Σy) ⁄ n
Syy = Σy² − (Σy)² ⁄ n
The slope and intercept are then calculated using:
斜率与截距的计算公式为:
b = Sxy ⁄ Sxx
a = ȳ − b x̄
Here, x̄ and ȳ are the means of the x and y data, respectively. The equation always passes through the point (x̄, ȳ).
其中 x̄ 和 ȳ 分别是 x 数据和 y 数据的平均值。回归直线总是经过点 (x̄, ȳ)。
4. Worked Example: Calculating b and a | 实例:计算 b 和 a
Consider the data set with pairs (x, y): (1, 2), (2, 3), (3, 5), (4, 6), (5, 7). We calculate the regression line step by step.
考虑以下数据点 (x, y):(1, 2)、(2, 3)、(3, 5)、(4, 6)、(5, 7)。我们逐步计算回归直线。
| x | y | x² | xy | y² |
| 1 | 2 | 1 | 2 | 4 |
| 2 | 3 | 4 | 6 | 9 |
| 3 | 5 | 9 | 15 | 25 |
| 4 | 6 | 16 | 24 | 36 |
| 5 | 7 | 25 | 35 | 49 |
| Σ = 15 | Σ = 23 | Σ = 55 | Σ = 82 | Σ = 123 |
With n = 5, we compute:
已知 n = 5,我们计算:
Sxx = 55 − 15² ⁄ 5 = 55 − 45 = 10
Sxy = 82 − (15 × 23) ⁄ 5 = 82 − 69 = 13
Thus the slope is b = 13 ⁄ 10 = 1.3. The means are x̄ = 15 ⁄ 5 = 3 and ȳ = 23 ⁄ 5 = 4.6. Therefore:
因此斜率 b = 13 ⁄ 10 = 1.3。均值 x̄ = 15 ⁄ 5 = 3,ȳ = 23 ⁄ 5 = 4.6。所以:
a = 4.6 − 1.3 × 3 = 4.6 − 3.9 = 0.7
The regression line is y = 0.7 + 1.3x.
回归直线为 y = 0.7 + 1.3x。
5. Interpreting the Slope and Intercept | 解读斜率和截距
The slope b = 1.3 means that for every additional unit of x, y increases by 1.3 units on average. The intercept a = 0.7 means that when x = 0, the predicted value of y is 0.7. However, if x = 0 is not in the observed data range, this intercept has no meaningful real-world interpretation; it is only a mathematical constant.
斜率 b = 1.3 表示 x 每增加一个单位,y 平均增加 1.3 个单位。截距 a = 0.7 表示当 x = 0 时,y 的预测值为 0.7。但如果 x = 0 不在观测数据范围内,这个截距没有实际意义,它只是一个数学常数。
6. Correlation Coefficient and Coefficient of Determination | 相关系数与决定系数
The Pearson product-moment correlation coefficient r measures the strength and direction of the linear relationship. It is calculated using:
皮尔逊积矩相关系数 r 用来衡量线性关系的强度和方向。其计算公式为:
r = Sxy ⁄ √(Sxx × Syy)
The value of r always lies between −1 and 1. For our example, Syy = 123 − 23² ⁄ 5 = 123 − 105.8 = 17.2. Therefore r = 13 ⁄ √(10 × 17.2) ≈ 0.991. This indicates a very strong positive linear relationship.
r 的值在 −1 和 1 之间。在例子中,Syy = 123 − 23² ⁄ 5 = 123 − 105.8 = 17.2,因此 r = 13 ⁄ √(10 × 17.2) ≈ 0.991。这说明两个变量之间存在极强的正线性关系。
The coefficient of determination, r², describes the proportion of the variance in y that is explained by the regression model. Here r² ≈ 0.982, meaning that roughly 98.2% of the variation in y is explained by x.
决定系数 r² 描述了 y 的方差中能被回归模型解释的比例。本例中 r² ≈ 0.982,意味着 y 的变异中约有 98.2% 可以由 x 解释。
7. Using the Regression Line for Prediction | 用回归直线进行预测
Once the regression line is established, we can substitute a given value of x into the equation to estimate the corresponding y. This process is called prediction. However, the reliability of the prediction depends heavily on whether we are interpolating or extrapolating.
一旦回归直线建立,我们就可以将给定的 x 值代入方程来估计相应的 y 值。这个过程称为预测。然而,预测的可靠性在很大程度上取决于我们是在进行内插还是外推。
8. Interpolation: Reliable Prediction within the Data Range | 内插法:在数据范围内进行可靠预测
Interpolation means predicting a y value for an x that lies within the observed range of the data. For example, in our data set the x values range from 1 to 5. Predicting y for x = 4.2 is interpolation. Since we are making a prediction inside the range where we already have evidence of a linear trend, the result is generally reliable, provided the linear model is appropriate.
内插法是指对位于观测数据范围之内的 x 值预测相应的 y 值。例如,在我们的数据集中,x 的范围是 1 到 5。对 x = 4.2 预测 y 就属于内插。由于我们在已有线性趋势证据的范围内进行预测,只要线性模型合适,结果通常是可靠的。
For x = 4.2, the regression line gives y = 0.7 + 1.3(4.2) = 6.16. Because this x is close to the centre of the data, the prediction is likely to be quite accurate.
对于 x = 4.2,回归直线给出 y = 0.7 + 1.3 × 4.2 = 6.16。由于这个 x 值接近数据的中心区域,预测结果很可能相当准确。
9. Extrapolation: The Danger of Predicting Outside the Range | 外推法:在数据范围外预测的风险
Extrapolation occurs when we predict a y value for an x that lies outside the observed range. For instance, using the same line to predict y at x = 12 or x = −3 is extrapolation. Although the formula will give a numerical answer, the result is not statistically justified. The linear relationship may not hold outside the data range, and the prediction can be seriously misleading.
外推法是指对位于观测范围之外的 x 值预测 y 值。例如,用同一条直线预测 x = 12 或 x = −3 时的 y 值就是外推。虽然公式会给出一个数值结果,但这个结果在统计上是不成立的。在数据范围之外,线性关系可能不再成立,预测结果可能会严重误导。
In IB exams, you are expected to state that extrapolation is unreliable because the trend may change outside the given data range. Always check whether your prediction x-value lies within the original data interval.
在 IB 考试中,你需要明确指出外推法不可靠,因为在给定数据范围之外趋势可能改变。务必检查你预测所用的 x 值是否落在原始数据的区间内。
10. Residuals and Model Fit | 残差与模型拟合
A residual is the difference between an observed y value and the y value predicted by the regression line. The residual for the ith data point is eᵢ = yᵢ − (a + b xᵢ). If we plot the residuals against x, we can check whether a linear model is appropriate.
残差是观测到的 y 值与回归直线预测的 y 值之差。第 i 个数据点的残差为 eᵢ = yᵢ − (a + b xᵢ)。如果我们绘制残差关于 x 的图,就可以检验线性模型是否合适。
If the residual plot shows no clear pattern, the linear model is appropriate. If a curve or funnel shape appears, the linear regression may not be valid, and predictions should not be made using the line.
如果残差图没有明显模式,说明线性模型是合适的。如果出现曲线或漏斗形状,则线性回归可能不适用,不应使用该直线进行预测。
11. Using Technology for Regression Analysis | 使用技术工具进行回归分析
In the IB syllabus, graphic display calculators (GDC) are commonly used to find the regression line, the correlation coefficient, and to draw residual plots. Enter the x and y lists, choose linear regression (LinReg), and the calculator outputs a, b, and r. This is faster and less prone to arithmetic error than manual calculation.
在 IB 课程中,图形计算器常用于求回归直线、相关系数以及绘制残差图。将 x 和 y 列表输入后,选择线性回归功能,计算器会直接输出 a、b 和 r。这比手算更快,也更不容易出现计算错误。
Nevertheless, you must understand the underlying formulas and interpretations. IB exam questions often expect you to explain what the numbers mean, not just obtain them from a calculator.
然而,你仍然需要理解公式背后的原理和含义。IB 考试题往往要求你解释这些数值的意义,而不仅仅是利用计算器得到结果。
12. Common Pitfalls and Exam Tips | 常见错误与备考提示
A common mistake is confusing y on x regression with x on y regression. The formula for b above is for predicting y from x; if you need to predict x from y, you must use a different regression line. Another pitfall is using interpolation language when the x value is outside the interval, or making predictions without checking the range.
常见错误包括混淆 y 关于 x 的回归与 x 关于 y 的回归。上述公式是用于由 x 预测 y 的;如果要用 y 预测 x,就需要使用不同的回归直线。另一个错误是 x 值在区间外时仍然说成内插,或者不检查范围就直接预测。
Exam tips: always write the line with clearly defined variables; state the units of the slope; comment on the reliability of predictions; and mention that interpolation is safer than extrapolation. Use r² to describe the strength of the model, and check residuals whenever possible.
备考建议:写回归方程时务必明确定义变量;注明斜率的单位;说明预测的可靠性;并指出内插比外推更安全。使用 r² 来描述模型强度,并在可能时检查残差图。
Published by TutorHao | Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply