Question

In: Math

Use R to complete the following questions. You should include your R code, output and plots...

Use R to complete the following questions. You should include your R code, output and plots in your answer.

1. Two methods of generating a standard normal random variable are:

a. Take the sum of 5 uniform (0,1) random numbers and scale to have mean 0 and standard deviation 1. (Use the properties of the uniform distribution to determine the required transformation).

b. Generate a standard uniform and then apply inverse cdf function to obtain a normal random variate (Hint: use qnorm).

For each method generate 10,000 random numbers and check the distribution using

a. Normal probability plot

b. Mean and standard deviation

c. The proportion of the data lying within the theoretical 2.5 and 97.5 percentiles and the 0.5 and 99.5 percentiles. (Hint: The ifelse function will be useful)  

Solutions

Expert Solution

r code :- random number generate and output

> ##### uniform random number (sample size n=5 )

> u=runif(n=5,0,1)
> u
[1] 0.01102249 0.39552950 0.78375498 0.02191521 0.75244598
> sum(u)
[1] 1.964668
> a=mean(u);a
[1] 0.3929336
> b=var(u);b
[1] 0.141377
> sd=sqrt(b);sd
[1] 0.3760013
> ####inverse method use genrate random number n=5
> u=runif(5)
> u
[1] 0.13909559 0.09987109 0.11123441 0.01423793 0.86949264
> a=qnorm(u);a
[1] -1.084392 -1.282286 -1.219990 -2.190668 1.123996
> b=mean(u);b
[1] 0.2467863
> c=var(u);c
[1] 0.1233494
> sd=sqrt(c);sd
[1] 0.3512113

> ##### uniform random number n=5
> u=runif(n=5,0,1)
> u
[1] 0.01102249 0.39552950 0.78375498 0.02191521 0.75244598
> sum(u)
[1] 1.964668
> a=mean(u);a
[1] 0.3929336
> b=var(u);b
[1] 0.141377
> sd=sqrt(b);sd
[1] 0.3760013
> ####inverse method use genrate random number n=5
> u=runif(5)
> u
[1] 0.13909559 0.09987109 0.11123441 0.01423793 0.86949264
> a=qnorm(u);a
[1] -1.084392 -1.282286 -1.219990 -2.190668 1.123996
> b=mean(u);b
[1] 0.2467863
> c=var(u);c
[1] 0.1233494
> sd=sqrt(c);sd
[1] 0.3512113
>

> ##### uniform random number n=5
> u=runif(n=5,0,1)
> u
[1] 0.01102249 0.39552950 0.78375498 0.02191521 0.75244598
> sum(u)
[1] 1.964668
> a=mean(u);a
[1] 0.3929336
> b=var(u);b
[1] 0.141377
> sd=sqrt(b);sd
[1] 0.3760013
> ####inverse method use genrate random number n=5
> u=runif(5)
> u
[1] 0.13909559 0.09987109 0.11123441 0.01423793 0.86949264
> a=qnorm(u);a
[1] -1.084392 -1.282286 -1.219990 -2.190668 1.123996
> b=mean(u);b
[1] 0.2467863
> c=var(u);c
[1] 0.1233494
> sd=sqrt(c);sd
[1] 0.3512113
> > ##### uniform random number n=5
> u=runif(n=5,0,1)
> u
[1] 0.01102249 0.39552950 0.78375498 0.02191521 0.75244598
> sum(u)
[1] 1.964668
> a=mean(u);a
[1] 0.3929336
> b=var(u);b
[1] 0.141377
> sd=sqrt(b);sd
[1] 0.3760013
> ####inverse method use genrate random number n=5
> u=runif(5)
> u
[1] 0.13909559 0.09987109 0.11123441 0.01423793 0.86949264
> a=qnorm(u);a
[1] -1.084392 -1.282286 -1.219990 -2.190668 1.123996
> b=mean(u);b
[1] 0.2467863
> c=var(u);c
[1] 0.1233494
> sd=sqrt(c);sd
[1] 0.3512113
> ############random rumber n=10000

> sum(u)

[1] 4987.53
> a=mean(u);a
[1] 0.498753
> b=var(u);b
[1] 0.08299141
> sd=sqrt(b);sd
[1] 0.2880823
> boxplot(u)
> hist(u)
> qqline(u)

Please hit like button


Related Solutions

Use R to complete the following questions. You should include your R code, output and plots...
Use R to complete the following questions. You should include your R code, output and plots in your answer. 1. Two methods of generating a standard normal random variable are: a. Take the sum of 5 uniform (0,1) random numbers and scale to have mean 0 and standard deviation 1. (Use the properties of the uniform distribution to determine the required transformation). b. Generate a standard uniform and then apply inverse cdf function to obtain a normal random variate (Hint:...
please use linux or unix to complete, and include pictures of the output. Modify the code...
please use linux or unix to complete, and include pictures of the output. Modify the code below to implement the program that will sum up 1000 numbers using 5 threads. 1st thread will sum up numbers from 1-200 2nd thread will sum up numbers from 201 - 400 ... 5th thread will sum up numbers from 801 - 1000 Make main thread wait for other threads to finish execution and sum up all the results. Display the total to the...
You have to include the appropriate output in your report. Your analysis output should be properly...
You have to include the appropriate output in your report. Your analysis output should be properly shaped such as changing the decimal points, copy, and pasted on to your report paper. when you label your output, specify what program did you use to bring the regression output. Ex: Excel Regression Analysis. Submit in one file using docs or PDF format. (1-2 page including regression output) Recognizing appropriate tools & performing all analysis that needs to be done Able to organize...
The following should be performed using R and the R code included in your submission. To...
The following should be performed using R and the R code included in your submission. To obtain first prize in a lottery, you need to correctly choose n different numbers from N and 1 number from 20, known as the supplementary. That is we first draw n numbers from 1:N without replacement and then 1 number from 1:20 in another draw. Suppose n=7 and N=35. Let X be the number of drawn numbers that match your selection, where the supplementary...
Using the R package to answer the following two questions. You MUST submit your R code...
Using the R package to answer the following two questions. You MUST submit your R code for analysis. 2. Below are heights for a simple random sample of n = 15 young trees (in cm). (50 pts) 27, 33, 33, 34, 36, 37, 39, 40, 40, 41, 41, 42, 44, 46, 47. (a) Test the hypothesis that the mean tree height is equal to 38 cm. (b) Calculate the 95% confidence interval for the population mean of young trees. (c)...
Answer the following questions using R (include both the input and output for each question). I)...
Answer the following questions using R (include both the input and output for each question). I) A random variable P has a Poisson distribution with a mean of 10. Solve for the probability that random variable P is greater than 8. II) What is the probability that in 30 tosses of a fair coin, the head comes up 10 or 15 times? III) What is the probability that a normal random variable is less than 40, assuming that the variable...
Answer the following questions using R (include both the input and output for each question). I)...
Answer the following questions using R (include both the input and output for each question). I) A random variable P has a Poisson distribution with a mean of 10. Solve for the probability that random variable P is greater than 8. II) What is the probability that in 30 tosses of a fair coin, the head comes up 10 or 15 times? III) What is the probability that a normal random variable is less than 40, assuming that it has...
Use Minitab and produce the appropriate output to answer the following questions. Attach or include the...
Use Minitab and produce the appropriate output to answer the following questions. Attach or include the relevant Minitab output. Construct a scatter plot. Recalling what scatter plots are used for, write a couple of sentences addressing what you observed from the plot. Be sure to relate your observations to the purpose of using scatter plots in regression. (4 points) Can we conclude that median family income helps in predicting median home price? Follow the 7 steps for hypothesis testing. (10...
1. Use R Studio: Include R Code A survey is taken of 250 students, and a...
1. Use R Studio: Include R Code A survey is taken of 250 students, and a phat of 0.48 is found. The same survey is repeated with 1000 students, and the same phat value is found. Compare the two 95% confidence intervals. What is the relationship between them? Is the margin of error for the second one four times smaller? If not, how much smaller is it?
(Be sure to paste the R Console Output and code!!!) Using the following data and R,...
(Be sure to paste the R Console Output and code!!!) Using the following data and R, write a brief paragraph about whether the in-home treatment is equally effective as the out-of-home treatment for two separate groups. Here are the data. The outcome variable is level of anxiety after treatment on a scale from 1 to 10. In-Home Treatment Out-of-Home Treatment 3 7 4 6 1 7 1 8 1 7 3 6 3 5 6 6 5 4 1 2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT