为什么计算样本标准差时,除以 N-1 而不是 N

标准差 是度量数据集离散度的一个重要指标,但是,本篇讨论的不是标准差 的作用和意义,

而是标准差计算中的一个细节问题。

实际情况下,一般会接触到两种标准差:总体标准差样本标准差,其中样本标准差是最常用的。

1. 总体标准差

总体标准差 的计算公式: <math xmlns="http://www.w3.org/1998/Math/MathML"> σ = 1 N ∑ i = 1 N ( x i − μ ) 2 \sigma = \sqrt{\frac{1}{N} \sum_{i=1}^N (x_i - \mu)^2} </math>σ=N1∑i=1N(xi−μ)2

其中, <math xmlns="http://www.w3.org/1998/Math/MathML"> N N </math>N是总的数据个数, <math xmlns="http://www.w3.org/1998/Math/MathML"> x i x_i </math>xi表示每个数据,
<math xmlns="http://www.w3.org/1998/Math/MathML"> μ \mu </math>μ是所有数据的平均值,即: <math xmlns="http://www.w3.org/1998/Math/MathML"> μ = 1 N ∑ i = 1 N x i \mu = \frac{1}{N} \sum_{i=1}^N x_i </math>μ=N1∑i=1Nxi

从公式来看,总体标准差很好理解,目的就是度量数据集中的数据偏离平均值的情况。

2. 样本标准差

再来看样本标准差 公式: <math xmlns="http://www.w3.org/1998/Math/MathML"> s = 1 N − 1 ∑ i = 1 N ( x i − x ˉ ) 2 s = \sqrt{\frac{1}{N-1} \sum_{i=1}^N (x_i - \bar{x})^2} </math>s=N−11∑i=1N(xi−xˉ)2

其中, <math xmlns="http://www.w3.org/1998/Math/MathML"> N N </math>N是样本集的数据个数, <math xmlns="http://www.w3.org/1998/Math/MathML"> x i x_i </math>xi表示每个样本数据,
<math xmlns="http://www.w3.org/1998/Math/MathML"> x ˉ \bar{x} </math>xˉ是样本数据的平均值,即: <math xmlns="http://www.w3.org/1998/Math/MathML"> x ˉ = 1 N ∑ i = 1 N x i \bar{x} = \frac{1}{N} \sum_{i=1}^N x_i </math>xˉ=N1∑i=1Nxi

从公式可以看出,样本标准差 计算时,用的 <math xmlns="http://www.w3.org/1998/Math/MathML"> 1 N − 1 \frac{1}{N-1} </math>N−11,而不是 <math xmlns="http://www.w3.org/1998/Math/MathML"> 1 N \frac{1}{N } </math>N1。

3. 为什么除以 (N-1)

为了区分总体标准差中 的数据个数,下面用 <math xmlns="http://www.w3.org/1998/Math/MathML"> N a l l N_{all} </math>Nall表示总体标准差 中的数据个数,

用 <math xmlns="http://www.w3.org/1998/Math/MathML"> N s a m p l e s N_{samples} </math>Nsamples表示样本标准差中的数据个数。

实际的数据分析中,常用的分析指标是样本标准差总体标准差 用的很少。

因为,总体数据量往往很庞大,而且新的数据不断产生,导致所谓的总体数据 也不断变化。

比如,对于民意调查结果,新闻内容,天气数据,股市交易等等,都是抽样做分析。

既然是抽样分析,那么,计算样本标准差时,是得不到整体数据的平均值 <math xmlns="http://www.w3.org/1998/Math/MathML"> μ \mu </math>μ的。

所以在样本标准差的计算公式中,我们用的是样本的平均值 <math xmlns="http://www.w3.org/1998/Math/MathML"> x ˉ \bar{x} </math>xˉ,而不是整体的平均值 <math xmlns="http://www.w3.org/1998/Math/MathML"> μ \mu </math>μ。

直观上来看,样本的平均值 <math xmlns="http://www.w3.org/1998/Math/MathML"> x ˉ \bar{x} </math>xˉ会要比整体的平均值 <math xmlns="http://www.w3.org/1998/Math/MathML"> μ \mu </math>μ更接近样本数据集中的数据,

所以,理论上 <math xmlns="http://www.w3.org/1998/Math/MathML"> ∑ i = 1 N s a m p l e s ( x i − x ˉ ) 2 \sum_{i=1}^{N_{samples}} (x_i - \bar{x})^2 </math>∑i=1Nsamples(xi−xˉ)2要比 <math xmlns="http://www.w3.org/1998/Math/MathML"> ∑ i = 1 N s a m p l e s ( x i − μ ) 2 \sum_{i=1}^{N_{samples}} (x_i - \mu)^2 </math>∑i=1Nsamples(xi−μ)2的值小一些。

因此, <math xmlns="http://www.w3.org/1998/Math/MathML"> 1 N s a m p l e s ∑ i = 1 N s a m p l e s ( x i − x ˉ ) 2 \frac{1}{N_{samples}}\sum_{i=1}^{N_{samples}} (x_i - \bar{x})^2 </math>Nsamples1∑i=1Nsamples(xi−xˉ)2也比 <math xmlns="http://www.w3.org/1998/Math/MathML"> 1 N s a m p l e s ∑ i = 1 N s a m p l e s ( x i − μ ) 2 \frac{1}{N_{samples}}\sum_{i=1}^{N_{samples}} (x_i - \mu)^2 </math>Nsamples1∑i=1Nsamples(xi−μ)2的值要小。

为了调整这个偏差,让样本标准差 能够更接近总体的标准差
样本标准差 公式中除以 <math xmlns="http://www.w3.org/1998/Math/MathML"> N s a m p l e s − 1 N_{samples}-1 </math>Nsamples−1而不是 <math xmlns="http://www.w3.org/1998/Math/MathML"> N s a m p l e s N_{samples} </math>Nsamples,

相当于调高了样本标准差的值,使之更接近**总体的标准差 **。

4. 补充

通过( <math xmlns="http://www.w3.org/1998/Math/MathML"> N s a m p l e s − 1 N_{samples}-1 </math>Nsamples−1)调节样本标准差 的过程也被称作贝塞尔校正Bessel's correction),

它的数学推导过程可以参考:贝塞尔校正

相关推荐
IpdataCloud16 小时前
大数据分析:如何高效查询海量IP归属地?
tcp/ip·数据挖掘·数据分析·ip
橙露16 小时前
特征选择实战:方差、卡方、互信息法筛选有效特征
人工智能·深度学习·机器学习
海森大数据17 小时前
数据与特征“协同进化”:机器学习加速发现高性能光合成过氧化氢COF催化剂
人工智能·机器学习
高洁0118 小时前
大模型微调进阶:多任务微调实战
人工智能·python·深度学习·机器学习·transformer
babe小鑫20 小时前
计算机专业转行数据分析可行吗?学数据分析有用吗
数据挖掘·数据分析
Code_Artist21 小时前
LangChainGo构建RAG应用实况:切分策略、文本向量化、消除幻觉
机器学习·langchain·llm
SelectDB技术团队21 小时前
基于 SelectDB 实现 Hive 数据湖统一分析:洋钱罐全球一体化探索分析平台升级实践
数据仓库·数据分析·apache doris·selectdb
Highcharts.js21 小时前
用 Highcharts 为日历赋予数据分析能力:Bryntum Calendar 的实践
数据挖掘·数据分析
研究点啥好呢1 天前
Github热门项目推荐 | 开放数据的新时代
大数据·人工智能·机器学习·github·数据
梦中的飞行家1 天前
IsaacSim/IsaacLab
机器学习