📚 Covariance and Correlation Coefficient | 协方差与相关系数
In statistics, we often want to know whether two variables move together. Does an increase in one variable tend to be accompanied by an increase in the other, or do they move in opposite directions? Covariance and the correlation coefficient are fundamental tools that measure the direction and strength of a linear relationship between two quantitative variables. In the IB Mathematics curriculum — whether you are studying Analysis and Approaches (AA) or Applications and Interpretation (AI) — these concepts are essential in the statistics and probability strand.
在统计学中,我们常常想知道两个变量是否一起变动。一个变量的增加是否往往伴随着另一个变量的增加,还是它们朝相反方向变动?协方差与相关系数是衡量两个定量变量之间线性关系的方向与强度的基本工具。在 IB 数学课程中——无论你学习的是分析与方法(AA)还是应用与解释(AI)——这些概念都是统计与概率板块的核心内容。
1. Bivariate Data and Scatter Plots | 双变量数据与散点图
Before calculating any numerical measure, we should always visualise the data. Bivariate data consist of paired observations (x, y), where one variable may be considered the explanatory (independent) variable and the other the response (dependent) variable. A scatter plot places each pair on a coordinate plane and reveals three features of the relationship: its form, direction and strength.
在计算任何数值度量之前,我们应始终先对数据进行可视化。双变量数据由成对的观测值 (x, y) 组成,其中一个变量可视为解释(自变量)变量,另一个视为响应(因变量)变量。散点图将每一对数据绘制在坐标平面上,揭示关系的三个特征:形态、方向与强度。
-
Form — linear, curved, or no clear pattern at all?
形态——线性的、弯曲的,还是根本没有明显模式?
-
Direction — positive (as x increases, y tends to increase) or negative (as x increases, y tends to decrease)?
方向——正向(x 增大时 y 趋于增大)还是负向(x 增大时 y 趋于减小)?
-
Strength — how tightly the points cluster around a straight line.
强度——各点围绕一条直线的聚集程度如何。
Both covariance and the correlation coefficient summarise the direction and strength of a linear pattern. However, as we shall see, covariance suffers from a serious limitation regarding units, which motivates the need for correlation.
协方差与相关系数都用于概括线性模式的方向与强度。然而,我们将会看到,协方差在单位问题上存在严重局限,这正是引入相关系数的原因。
2. Covariance: Definition and Formula | 协方差:定义与公式
Covariance measures how two variables deviate from their means together. For a population of n data pairs, the population covariance is defined as the average product of the deviations from the respective means:
协方差衡量两个变量如何偏离各自均值并“一起”变动。对于包含 n 对数据的总体,总体协方差定义为各点与其均值之偏差的乘积的平均值:
Cov(X,Y) = Σ(xᵢ − x̄)(yᵢ − ȳ) / n
where x̄ and ȳ are the population means of X and Y, and the summation is taken over all n data pairs. For a sample, we replace the population means with the sample means and divide by (n − 1) instead of n:
其中 x̄ 与 ȳ 分别是 X 与 Y 的总体均值,求和遍历所有 n 对数据。对于样本,我们用样本均值代替总体均值,并将除数由 n 改为 (n − 1):
sₓᵧ = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1)
The symbol sₓᵧ is used for the sample covariance to distinguish it from the population parameter. In IB exam questions, you must read carefully whether a dataset is treated as a whole population or as a sample from a larger population.
符号 sₓᵧ 用于表示样本协方差,以区别于总体参数。在 IB 考试题目中,你必须仔细判断一组数据是被视为完整总体,还是来自更大总体的样本。
3. Interpreting Covariance | 解释协方差
The sign of the covariance tells us about the direction of the relationship:
协方差的符号告诉我们关系的方向:
-
If Cov(X,Y) > 0, then when x is above its mean, y tends to be above its mean as well. The variables are positively associated.
若 Cov(X,Y) > 0,则当 x 高于其均值时,y 也往往高于其均值。变量之间存在正相关。
-
If Cov(X,Y) < 0, then when x is above its mean, y tends to be below its mean. The variables are negatively associated.
若 Cov(X,Y) < 0,则当 x 高于其均值时,y 往往低于其均值。变量之间存在负相关。
-
If Cov(X,Y) = 0, there is no linear tendency, though a non-linear relationship may still exist.
若 Cov(X,Y) = 0,则不存在线性趋势,但仍可能存在非线性关系。
However, the magnitude of covariance is difficult to interpret. The numerical value depends on the units of measurement: if you measure heights in centimetres and weights in kilograms, then switch to metres and grams, the covariance changes even though the underlying relationship is identical. This scale-dependence makes covariance unsuitable for comparing relationships across different datasets.
然而,协方差的数值大小难以解释。其数值取决于测量单位:如果你用厘米测身高、用千克测体重,再换成米和克,尽管本质关系完全相同,协方差也会发生变化。这种对尺度的依赖使得协方差不适用于比较不同数据集之间的关系。
4. Properties of Covariance | 协方差的性质
Several algebraic properties of covariance are frequently tested or used in simplifying calculations:
协方差的若干代数性质经常被考查,也可用于简化计算:
-
Cov(X, X) = Var(X) — the covariance of a variable with itself equals its variance.
Cov(X, X) = Var(X)——变量与其自身的协方差等于它的方差。
-
Cov(X, Y) = Cov(Y, X) — covariance is symmetric.
Cov(X, Y) = Cov(Y, X)——协方差具有对称性。
-
Cov(aX + b, cY + d) = ac·Cov(X, Y), where a, b, c, d are constants.
Cov(aX + b, cY + d) = ac·Cov(X, Y),其中 a、b、c、d 为常数。
-
Cov(X, Y) cannot exceed σₓσᵧ in absolute value, a result of the Cauchy–Schwarz inequality.
Cov(X, Y) 的绝对值不可能超过 σₓσᵧ,这是柯西–施瓦茨不等式的结论。
-
If X and Y are independent, then Cov(X, Y) = 0. The converse is not always true.
若 X 与 Y 独立,则 Cov(X, Y) = 0;但反之不一定成立。
These properties remind us that covariance is essentially a scaled measure of linear association; it is symmetric, linear in each argument, and bounded by the product of the standard deviations.
这些性质提醒我们,协方差本质上是一种经过放缩的线性关联度量;它是对称的,对每个变量都是线性的,并且以两个标准差的乘积为上界。
5. Standardising: Pearson’s Correlation Coefficient | 标准化:皮尔逊相关系数
To eliminate the unit problem, we divide the covariance by the product of the standard deviations. This gives the Pearson product-moment correlation coefficient:
为了消除单位问题,我们用协方差除以两个标准差的乘积,得到皮尔逊积矩相关系数:
ρ = Cov(X,Y) / (σₓσᵧ)
for a population, and
对于总体使用上式,而对于样本:
r = sₓᵧ / (sₓsᵧ)
Notice that when we use sample formulas for sₓᵧ, sₓ and sᵧ, the factor 1/(n − 1) appears in all three quantities and cancels out. Consequently, we may also write:
注意,当我们使用样本公式计算 sₓᵧ、sₓ 与 sᵧ 时,因子 1/(n − 1) 在三个量中都会出现并相互抵消。因此,我们也可以写成:
r = Σ(xᵢ − x̄)(yᵢ − ȳ) / √(Σ(xᵢ − x̄)² · Σ(yᵢ − ȳ)²)
This formula is convenient for hand calculation and is often the most reliable way to compute r in an IB exam when a calculator is not permitted for the working.
这个公式便于手算,也是 IB 考试中不允许使用计算器计算时最可靠的求 r 方法。
6. Properties of the Correlation Coefficient | 相关系数的性质
Since the covariance is divided by the product of the standard deviations, the correlation coefficient is dimensionless and always lies between −1 and 1:
由于协方差除以了两个标准差的乘积,相关系数没有量纲,且始终介于 −1 与 1 之间:
−1 ≤ r ≤ 1
-
r = 1 indicates a perfect positive linear relationship: all points lie exactly on a line with positive slope.
r = 1 表示完全正线性关系:所有点恰好落在一条斜率为正的直线上。
-
r = −1 indicates a perfect negative linear relationship: all points lie exactly on a line with negative slope.
r = −1 表示完全负线性关系:所有点恰好落在一条斜率为负的直线上。
-
r = 0 indicates no linear relationship; however, the points may still follow a curved pattern.
r = 0 表示不存在线性关系;但各点仍可能遵循某种曲线模式。
-
The closer |r| is to 1, the stronger the linear association; the closer to 0, the weaker.
|r| 越接近 1,线性关联越强;越接近 0,则越弱。
An important property is that r is invariant under linear transformations with a positive scale factor. This means that changing units — for example from centimetres to metres — does not alter r. Moreover, r measures only the strength of a linear relationship; a large |r| does not imply that the points follow any other type of curve.
一个重要性质是:r 在正数比例因子的线性变换下保持不变。这意味着改变单位——例如从厘米换算为米——不会改变 r。此外,r 仅仅衡量线性关系的强度;|r| 很大并不意味着各点遵循任何其他类型的曲线。
7. Worked Example | 完整例题
Consider the following five data pairs: (1, 2), (2, 1), (3, 4), (4, 3), (5, 5). Compute the covariance and the correlation coefficient.
考虑以下五对数据:(1, 2)、(2, 1)、(3, 4)、(4, 3)、(5, 5)。计算协方差与相关系数。
First find the means: x̄ = 15/5 = 3 and ȳ = 15/5 = 3. We then construct a table of deviations and products:
首先求出均值:x̄ = 15/5 = 3,ȳ = 15/5 = 3。然后构造偏差与乘积表:
| x | y | x − x̄ | y − ȳ | (x − x̄)(y − ȳ) | |
| 1 | 2 | −2 | −1 | 2 | |
| 2 | 1 | −1 | −2 | 2 | |
| 3 | 4 | 0 | 1 | 0 | |
| 4 | 3 | 1 | 0 | 0 | |
| 5 | 5 | 2 | 2 | 4 | |
| Σ | 15 | 15 | 0 | 0 | 8 |
The population covariance is Cov(X,Y) = 8/5 = 1.6. Since the covariance is positive, the variables are positively associated. Next compute the sums of squared deviations: Σ(x − x̄)²
Published by TutorHao | IB Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导