GaryBAYLOR / R-code

A collection of algorithms written by myself for solving statistical problems
0 stars 0 forks source link

Sample mean and sample variance is independent for normal distribution #13

Closed GaryBAYLOR closed 9 years ago

GaryBAYLOR commented 9 years ago
mean_var_indep <- function(n) {
    m <- v <- numeric(n)
    for (i in 1:n) {
        temp <- rnorm(n)
        m[i] <- mean(temp)
        v[i] <- var(temp)       
    }
    res <- cor(m, v)
    return(res)
}