4

var, sd,cor函数{stats}用作n-1分母(其中n观察数)。出于好奇,是否有等效的函数n用作分母?

4

1 回答 1

3

尝试这个:

library(RH2) # needs Java
library(sqldf)

n <- length(BOD$demand)

sd(BOD$demand)
sqrt((n-1)/n) * sd(BOD$demand)
sqldf("select stddev_samp(demand) as samp, stddev_pop(demand) as pop from BOD")

var(BOD$demand)
(n-1)/n * var(BOD$demand)
sqldf("select var_samp(demand) as samp, var_pop(demand) as pop from BOD")    
于 2014-01-26T00:01:19.977 回答