3

如果可能,请帮助我加快下面的引导代码。

sampleOne   <- function(x) sample(x, replace = TRUE)
sampleMany  <- function(x, n) replicate(n, sampleOne(x), simplify = FALSE)
listMeans <- function(x, n) lapply(sampleMany(x, n), mean)
bootData <- function(x,n) do.call(rbind, listMeans(x,n))
sampleSize <- 100000
numBoots <- 1000
# Left Skewed distribution # shape1 = a and shape2 = b
set.seed(400)
popSkewLeft <- rbeta(sampleSize, shape1 = 5, shape2 = 1)
skewLeftbootData <- bootData(popSkewLeft, numBoots)
(bootSd <- sd(skewLeftbootData) * sqrt(sampleSize))

我知道我可以使用引导包,但我的目标是磨练我在基础 R 方面的技能

4

0 回答 0