什么是sigma剪辑?你怎么知道什么时候申请呢?

NRH*_*NRH 1 python statistics numpy pandas data-science

我正在阅读一本关于Python的数据科学的书,作者应用'sigma-clipping operation'来删除因拼写错误而导致的异常值.但是,该过程根本没有解释.

什么是sigma剪辑?它是否仅适用于某些数据(例如,它用于美国的出生率)?

根据文字:

quartiles = np.percentile(births['births'], [25, 50, 75]) #so we find the 25th, 50th, and 75th percentiles
mu = quartiles[1] #we set mu = 50th percentile
sig = 0.74 * (quartiles[2] - quartiles[0]) #???

This final line is a robust estimate of the sample mean, where the 0.74 comes 
from the interquartile range of a Gaussian distribution.
Run Code Online (Sandbox Code Playgroud)

为何0.74?有证据吗?

kaz*_*ase 7

最后一行是样本均值的稳健估计,其中0.74来自高斯分布的四分位数范围.

就是这样,真的......

该代码尝试使用四分位数范围来估计sigma,以使其对异常值具有鲁棒性.0.74是校正因子.以下是如何计算它:

p1 = sp.stats.norm.ppf(0.25)  # first quartile of standard normal distribution
p2 = sp.stats.norm.ppf(0.75)  # third quartile
print(p2 - p1)  # 1.3489795003921634

sig = 1  # standard deviation of the standard normal distribution  
factor = sig / (p2 - p1)
print(factor)  # 0.74130110925280102
Run Code Online (Sandbox Code Playgroud)

在标准正态分布sig==1和四分位数范围内1.35.0.74将四分位数范围转换为sigma的修正系数也是如此.当然,这仅适用于正态分布.


Ken*_*Wei 5

假设你有一组数据。计算它的中位数m和标准差sigma。对于 的某个值,仅保留落在范围 ( m-a*sigma, m+a*sigma)内的数据a,并丢弃其他所有数据。这是 sigma 裁剪的一次迭代。继续迭代预定次数,和/或当 sigma 值的相对减少很小时停止。

Sigma 裁剪旨在去除异常值,以允许对分布的均值进行更稳健(即抵抗异常值)的估计。因此它适用于您希望找到异常值的数据。

至于 0.74,它来自高斯分布的四分位距,如文本所示。