I'm having issue with this question whereby I'm asked to generate 1000 sample mean observations from a binomial distribution in r studio. The binomial distrbution has a probability of 0.3, while #of trials = 10. Sample size is 3, and based on that I need to generate 1000 sample mean observations. So this is the code I entered in R Studio:
x = rep(0,1000)
for(i in 1:1000){
x[i] = mean(sample(c(0:10)), 3, prob = c(dbinom(0:10, 10, 0.3)), replace = T)}
x
However, when I ran this code, I get the same number for all 1000 sample mean observations. Could anyone help me with this? Thanks!
rbinom(3, 10, 0.3)generates a vector containing three independent draws of the $\text{Binomial}(10, 0.3)$ distribution; taking the mean of these three numbers gives you one sample mean. Repeat 1000 times.