📚 6B Covariance and Correlation | 协方差与相关系数
When we collect data that consist of paired measurements on two variables, such as height and weight or study hours and exam scores, we are dealing with bivariate data. In IB Mathematics, learning how to measure and interpret the relationship between two quantitative variables is essential. Covariance gives us a numerical measure of how two variables change together, while correlation standardises this measure to a dimensionless scale, making it easier to compare across different contexts.
当数据包含两个变量的成对观测值时,例如身高与体重、学习时间与考试成绩,我们处理的就是双变量数据。在 IB 数学中,衡量并解释两个定量变量之间的关系至关重要。协方差从数值上告诉我们两个变量如何共同变化,而相关系数将这个度量标准化到一个无单位的尺度上,便于跨情境比较。
1. Introduction to Bivariate Data | 双变量数据简介
Bivariate data arise when we observe two characteristics for each individual in a sample. A classic example is recording the number of hours spent revising and the corresponding test score for each student. Analysing such data allows us to explore whether an association exists, describe its direction, form, and strength, and eventually model it using a line of best fit.
当我们记录样本中每个个体的两个特征时,就产生了双变量数据。一个经典例子是记录每位学生的复习小时数和对应的考试成绩。分析这类数据可以让我们探究是否存在关联,描述其方向、形式和强度,并最终用最佳拟合线进行建模。
Before diving into calculations, we often visualise bivariate data using a scatter plot. The pattern of points can suggest a positive or negative trend, a linear or curved relationship, and the presence of any outliers. Covariance and correlation provide numerical summaries that complement these visual insights.
在深入计算之前,我们通常使用散点图来可视化双变量数据。点的分布模式可以显示出正趋势或负趋势、线性或曲线关系,以及是否存在异常值。协方差和相关系数提供了数值摘要,与这些视觉信息互为补充。
2. Understanding Covariance | 理解协方差
ovariance is defined as the expected product of deviations from the means, Cov(X,Y) = E[(X – μₓ)(Y – μᵧ)].
协方差衡量两个变量的共同变异性。若较大的 x 值倾向于与较大的 y 值配对,我们就得到正的协方差;若较大的 x 值与较小的 y 值配对,协方差为负。数学上,总体协方差定义为与均值离差乘积的期望值,即 Cov(X,Y) = E[(X – μₓ)(Y – μᵧ)]。
For a sample of size n, we replace the expectation with an average, using the sample means x̄ and ȳ. Because we are estimating a population parameter, we divide by n – 1 to obtain an unbiased estimator. This gives the familiar formula that appears in your formula booklet.
对于容量为 n 的样本,我们用样本均值 x̄ 与 ȳ 代替期望,使用平均值。由于我们在估计总体参数,会除以 n – 1 以获得无偏估计量。这就得到了公式手册中常见的式子。
3. Calculating Sample Covariance | 样本协方差的计算
The sample covariance sxy (often denoted Cov(x,y)) is computed as:
样本协方差 sxy(通常记作 Cov(x,y))的计算公式为:
Cov(x,y) = (1/(n – 1)) Σ (xᵢ – x̄)(yᵢ – ȳ)
To obtain it, follow these steps: (1) Compute the sample means x̄ and ȳ. (2) For each data point, find the deviations (xᵢ – x̄) and (yᵢ – ȳ). (3) Multiply the corresponding deviations for each pair. (4) Sum all these products. (5) Divide that sum by n – 1.
为计算协方差,需遵循以下步骤:(1) 计算样本均值 x̄ 和 ȳ。(2) 对每个数据点,计算离差 (xᵢ – x̄) 和 (yᵢ – ȳ)。(3) 将每对离差相乘。(4) 求所有这些乘积的总和。(5) 将该总和除以 n – 1。
The unit of covariance is the product of the units of x and y. For instance, if x is in kilograms and y in centimetres, the covariance is in kg·cm. This dependence on units makes it difficult to judge the strength of a relationship from the covariance alone.
协方差的单位是 x 和 y 单位的乘积。例如,若 x 以千克为单位,y 以厘米为单位,协方差的单位就是千克·厘米。这种对单位的依赖性使得仅凭协方差难以判断关系的强弱。
4. Worked Example of Covariance | 协方差计算实例
x, y): (1, 2), (2, 4), (3, 5), (4, 4), (5, 6). The first step is to calculate the means: x̄ = (1+2+3+4+5)/5 = 3, and ȳ = (2+4+5+4+6)/5 = 4.2.
考虑以下包含五组成对观测值的数据 (x, y):(1, 2), (2, 4), (3, 5), (4, 4), (5, 6)。第一步是计算均值:x̄ = (1+2+3+4+5)/5 = 3,ȳ = (2+4+5+4+6)/5 = 4.2。
| xᵢ | yᵢ | xᵢ – x̄ | yᵢ – ȳ | Product |
|---|---|---|---|---|
| 1 | 2 | –2 | –2.2 | 4.4 |
| 2 | 4 | –1 | –0.2 | 0.2 |
| 3 | 5 | 0 | 0.8 | 0.0 |
| 4 | 4 | 1 | –0.2 | –0.2 |
| 5 | 6 | 2 | 1.8 | 3.6 |
The sum of the products Σ (xᵢ – x̄)(yᵢ – ȳ) = 4.4 + 0.2 + 0.0 – 0.2 + 3.6 = 8.0. Since n = 5, the sample covariance is Cov(x,y) = 8.0 / (5 – 1) = 2.0.
乘积之和 Σ (xᵢ – x̄)(yᵢ – ȳ) = 4.4 + 0.2 + 0.0 – 0.2 + 3.6 = 8.0。由于 n = 5,样本协方差为 Cov(x,y) = 8.0 / (5 – 1) = 2.0。
The positive value indicates that x and y tend to increase together in this sample. However, without a scale-independent measure, we cannot easily say whether 2.0 represents a strong or weak association.
正值表明在该样本中 x 和 y 倾向于同时增加。然而,如果没有一个与尺度无关的度量,我们很难断言 2.0 代表强关联还是弱关联。
5. From Covariance to Correlation | 从协方差到相关系数
Because covariance depends on the units of x and y, comparing covariances across problems is not meaningful. We standardise it by dividing by the product of the sample standard deviations, sx and sy. This yields Pearson’s correlation coefficient r, which always lies between –1 and 1.
由于协方差依赖于 x 和 y 的单位,直接比较不同问题中的协方差没有意义。我们通过除以样本标准差 sx 和 sy 的乘积来将其标准化。这样就得到了皮尔逊相关系数 r,其值始终介于 –1 到 1 之间。
r = Cov(x,y) / (sx sy) = Σ (xᵢ – x̄)(yᵢ – ȳ) / √[ Σ (xᵢ – x̄)² × Σ (yᵢ – ȳ)² ]
Using the previous example, we need Σ (xᵢ – x̄)² = (–2)² + (–1)² + 0² + 1² + 2² = 10, and Σ (yᵢ – ȳ)² = (–2.2)² + (–0.2)² + 0.8² + (–0.2)² + 1.8² = 4.84 + 0.04 + 0.64 + 0.04 + 3.24 = 8.8. Therefore, r = 8.0 / √10 × 8.8 = 8.0 / √88 / 9.3808 ≈ 0.853. The correlation of 0.853 suggests a strong positive linear relationship.
沿用上例,我们需要 Σ (xᵢ – x̄)² = (–2)² + (–1)² + 0² + 1² + 2² = 10,以及 Σ (yᵢ – ȳ)² = (–2.2)² + (–0.2)² + 0.8² + (–0.2)² + 1.8² = 4.84 + 0.04 + 0.64 + 0.04 + 3.24 = 8.8。因此,r = 8.0 / √(10 × 8
Published by TutorHao | IB Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图