Using R Studio
Now, set the seed to 348 with `set.seed()`. Then take a sampleof size 10,000 from a normal distribution with a mean of 82 and astandard deviation of 11.
(a) Using sum() on a logical vector, how many draws are lessthan 60? Using mean() on a logical vector, what proportion of thetotal draws is that? How far is your answer from pnorm() in 1.1above?
```{R}
set.seed(348)
x=rnorm(10000,82,11)
sum(ifelse(x<60,1,0))
mean(ifelse(x<60,1,0))
pnorm(60,82,11)
Using sum() function there are 128 draws that are less than 60and using the mean() function 0.0281 is the porportion of totaldraws. From these outputs we can say that the answer is quite closeto the pnorm() value that has been calculated.
(b) What proportion of your sample is greater than 110 or lessthan 54?
(c) Why are your answers close to what you got above? Why arethey not exactly the same?
(d) Using ggplot2, make a histogram of your sample. Sety=..density.. inside aes(). Overlay a normal distribution withstat_function(aes(samp), fun=dnorm, args=list(82,11)). Usinggeom_vline(xintercept=), add dashed vertical lines corresponding tothe 2.5th and the 97.5th percentile of the sample