Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please give all the R-studio coding for all parts. Question 3:(a) Generate a ran

ID: 3277248 • Letter: P

Question


Please give all the R-studio coding for all parts.

Question 3:(a) Generate a random sample of size 10 from exponential dis- tribution with = 1 using the command rexp(nk) where n is the number of samples to be generated and k is the parameter of exponential distribution and store into a vector named "exprobs". Type the command set.seed (3585) start of the your R codes to enable you to generate similar samples b) Use the rep function to create a new vector "newexprobs" that consists of the first value of "exprobs" repeated 1 time, the second value of "exprobs" repeated 2 times, the third value of "exprobs" repeated 3 times, value of "exprobs" repeated 10 times c) Calculate the mean, standard deviation, 25% quantile and 75% quantile of your new vector "newexprobs" the 10th

Explanation / Answer

> set.seed(3585)
>
> ## a)
> exprobs=rexp(10,1)
> exprobs
[1] 0.65988257 1.04304028 0.04589163 1.28298864 2.46789697 1.99693847
[7] 1.85585207 0.66871055 0.07491813 0.06275139
>
> # b)
>
> newexprobs=rep(exprobs, c(1:10))
> newexprobs
[1] 0.65988257 1.04304028 1.04304028 0.04589163 0.04589163 0.04589163
[7] 1.28298864 1.28298864 1.28298864 1.28298864 2.46789697 2.46789697
[13] 2.46789697 2.46789697 2.46789697 1.99693847 1.99693847 1.99693847
[19] 1.99693847 1.99693847 1.99693847 1.85585207 1.85585207 1.85585207
[25] 1.85585207 1.85585207 1.85585207 1.85585207 0.66871055 0.66871055
[31] 0.66871055 0.66871055 0.66871055 0.66871055 0.66871055 0.66871055
[37] 0.07491813 0.07491813 0.07491813 0.07491813 0.07491813 0.07491813
[43] 0.07491813 0.07491813 0.07491813 0.06275139 0.06275139 0.06275139
[49] 0.06275139 0.06275139 0.06275139 0.06275139 0.06275139 0.06275139
[55] 0.06275139

> # b)
>
> newexprobs=rep(exprobs, c(1:10))
> newexprobs
[1] 0.65988257 1.04304028 1.04304028 0.04589163 0.04589163 0.04589163
[7] 1.28298864 1.28298864 1.28298864 1.28298864 2.46789697 2.46789697
[13] 2.46789697 2.46789697 2.46789697 1.99693847 1.99693847 1.99693847
[19] 1.99693847 1.99693847 1.99693847 1.85585207 1.85585207 1.85585207
[25] 1.85585207 1.85585207 1.85585207 1.85585207 0.66871055 0.66871055
[31] 0.66871055 0.66871055 0.66871055 0.66871055 0.66871055 0.66871055
[37] 0.07491813 0.07491813 0.07491813 0.07491813 0.07491813 0.07491813
[43] 0.07491813 0.07491813 0.07491813 0.06275139 0.06275139 0.06275139
[49] 0.06275139 0.06275139 0.06275139 0.06275139 0.06275139 0.06275139
[55] 0.06275139
>
> # c)
> mean(newexprobs) # mean
[1] 0.9450752
> sd(newexprobs) # standard deviation
[1] 0.8843645
>
> quantile(newexprobs, probs = c(0.25, 0.75))
25% 75%
0.07491813 1.85585207