-1

How can I plot graph for sample variance versus sample size while putting random numbers from 1 to 20 in R language?

4

1 回答 1

5

特林克可能会讨厌我回答这个问题,但这是一个带有许多假设的粗略示例:

sample.max <- 20000
sample.sizes <- seq(1, sample.max, by=10)

myfun <- function (x){
var(sample(1:20, x, replace=TRUE))
}

variances <- sapply(sample.sizes, myfun)

plot(sample.sizes, variances, t='l')

在此处输入图像描述

于 2013-02-17T03:06:20.627 回答