Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use R finish (b),(c), and (d) 2. Let X1, ..., Xn be iid with the Exponential distribution with mean ji > 0. (a) (4
Please use R finish (b),(c), and (d)
2. Let X1, ..., Xn be iid with the Exponential distribution with mean ji > 0. (a) (4 points) Write an R function called myrexp that generates a realization of X1,..., Xn. Only calls to R's standard uniform generator runif are permitted, eg. calling rexp is not allowed. This function should have two arguments: n, the random sample size mu, the user-specified mean of the exponential distribution This function should return a vector of n entries with the generated realization of X1,...,xn (b) (5 points) Test myrexp by generating a realization of X1, ..., X2000 iid with the Expo- nential distribution with some mean p > 0 that you pick. Create a QQ-plot to compare the data percentiles (of the realization of the random sample) to the percentiles of the Exponential distribution with mean 4. Only use the 1st, 2nd, 3rd, ..., 99th percentiles (so the plot has 99 points). Calling the function qexp is not allowed here. (e) (10 points) Let X = n-1=1 X; be the (random) sample mean. Write an R function called run.exp.sim that generates a realization of reps independent copies of X with sample size n. This function should have three arguments: n the sample size mu the mean of the exponential distribution reps the number of realizations of X The function should return a vector of reps realizations of X and display a QQ-plot of comparing the data percentiles of the entries in this vector to the percentiles of the fitted Normal distribution. Use reps data percentiles (so the plot has reps points). Calling the function qqnorm is not allowed. However, you can use the function qnorm. (d) (5 points) A civil engineer measured the times between vehicle arrivals at a rural bridge on a Sunday afternoon. For a simple model, she assumes that her measured inter- arrival times in minutes) 21, ..., 230 are a realization of X1, ..., X30 with the exponential distribution with unknown mean p. She computes the observed sample mean i = (1/30) 239 1; to estimate f. Is this sample size of 30 large enough for to be a rcalization of random variable with a distribution well approximated by the Normal distribution? To respond, pretend that = 2.5 minutes and perform a simulation study using the function run.exp.sim with reps=10000. Comment on the result. with the exponential distribution xi..xn be iid with mean Mso a) - function (n, mu) myrenp { ue- runif(n, min=0 manal) N . -log (1-4)*mu return (m) } 6) nic-10; mute-2 > myrepp (ni, mul) 4-6976 2.0085 2.4400 1.3013 7.3072 [ ] 1.5202 (7) laror 1.816b 3.5mg 0-9741 I n2c-15; mu2 2 -20 myremp (na muz) [!] 06.1598 1-5466 21-2017 26.4677 37,385 or 01 23.0753 27.0512 67 10.4644 3.1509 u surg 18.6386 [17] 2u.grsr 10-9612 27.0817 LelStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started