R 中的标准偏差似乎返回了错误的答案 - 我做错了什么吗? [英] Standard Deviation in R Seems to be Returning the Wrong Answer - Am I Doing Something Wrong?

查看:37
本文介绍了R 中的标准偏差似乎返回了错误的答案 - 我做错了什么吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计算标准偏差的简单例子:

A simple example of calculating standard dev:

d <- c(2,4,4,4,5,5,7,9)
sd(d)

收益

[1] 2.13809

但是当手工完成时,答案是 2.我在这里遗漏了什么?

but when done by hand, the answer is 2. What am I missing here?

推荐答案

试试这个

R> sd(c(2,4,4,4,5,5,7,9)) * sqrt(7/8)
[1] 2
R> 

并查看维基百科文章的其余部分,了解关于标准差估计的讨论.使用手工"使用的公式会导致估计有偏差,因此需要对 sqrt((N-1)/N) 进行更正.这是一个关键引述:

and see the rest of the Wikipedia article for the discussion about estimation of standard deviations. Using the formula employed 'by hand' leads to a biased estimate, hence the correction of sqrt((N-1)/N). Here is a key quote:

项的标准差样本用于未校正的估计量(使用 N)而术语样本标准差用于校正后的估计量(使用 N − 1).分母 N − 1 是向量中的自由度残差,.

The term standard deviation of the sample is used for the uncorrected estimator (using N) while the term sample standard deviation is used for the corrected estimator (using N − 1). The denominator N − 1 is the number of degrees of freedom in the vector of residuals, .

这篇关于R 中的标准偏差似乎返回了错误的答案 - 我做错了什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆