Menu

Loop 1 Write R Code Define Function Keeps Drawing Random Number N 0 1 Number Positive Use Q43837505

Loop and If

1. Write an R code to define a function which keeps drawing arandom number from N(0,1) until the number is positive. Use“rnorm()” and ”while()” to answer this question.

• You are generating a random draw from a truncated normaldistribution.
2. Write an R code to repeat the previous function for 100 times.Use “for()” to answer this question.

3. Take the sample mean of 100 values you have generated. (Itshould be near 0.7979.)

Expert Answer


Answer to Loop and If 1. Write an R code to define a function which keeps drawing a random number from N(0,1) until the number is …

OR