James Lucas
James Lucas

Reputation: 1

How to generate samples of uniform random variable and count how many times 2*mean is greater than upper parameter

I don't know how to write the code to generate 1000 experiments of a uniform random variable between 0 and 10 with 10 data points such that it counts and returns to me how many times twice the mean of the sample points is greater than 10 and was hoping for some help with it. Thank you

Upvotes: 0

Views: 95

Answers (1)

David L Thiessen
David L Thiessen

Reputation: 694

results <- rep(x=0,times=1000)
for(i in 1:1000) {
  dat <- runif(n=10,min=0,max=10)
  if(mean(dat) >= 5) {
    results[[i]] <- 1
  }
}
sum(results)

Upvotes: 1

Related Questions