Using R, I am instructed to generate 1000 random numbers in between 0 and 1, which I did using runif (1000). Then I am told to approximate the probability of the random number being in between 0.4 and 0.6. I am new to R and would love any help. Thanks.
You can do it like that:
a= runif(1000)
d= a > 0.4 & a < 0.6
sum(d)/1000
The last line is the approximated probability.