-2
The exercise is:
Using the function repeat
, gere 1000
samples of normal distribution, each of equal sample size n
and mean and standard deviation parameters equal to µ
and σ
, respectively. Choose the values for n
, µ
and σ
.
For each generated database, calculate Z = (¯x − µ)/(σ/p(n))
in which x¯
is the sample average.
Calculate the proportion of samples that lead to values for Z
smaller than -1,96
or greater than 1,96
.
I was trying to calculate first ¯x
, but I couldn’t even do that.
Follows the code:
f10 <- function(n, mean, sigma) {
lista <- numeric(1000)
i <- 1
repeat{
output <- rnorm(n, mean = mean, sd = sigma)
lista[i] <- mean(output)
if(i>1000) break()
}
i <- i+1
return(lista)
}