HW9 SOLUTIONS 10/19/16 =========================== (1) If X_i are independent random variables with X_1 ~ Expon(1), X_2 ~ Unif[-1,1], X_3 ~ t_{8} (Student's t, 8df) we want to calculate or estimate via Simulation the probability P(X_1 + X_2 + X_3 > 4) (a) The exact answer is a convolution-type integral (over the whole line) \int { 1 - pt(4-t,8) } g(t) dt where the convolution of the Unif and Expon densities give g(t) = 0.5*exp(-t)*(exp(min(1,t))-exp(-1)) , all t > -1 = 0 for t < -1 > integrate(function(x) 0.5*exp(-x)*(exp(pmin(1,x))-exp(-1))* (1-pt(4-x,8)), -1,Inf) 0.04233057 with absolute error < 8e-05 (b) Straightforward simulation: > Xmat = cbind(rexp(1e6), runif(1e6,-1,1), rt(1e6,8)) Xvec = c(Xmat %*% rep(1,3)) > mean(Xvec > 4) + (qnorm(0.995)/1e3)*c(-1,1)*sd(Xvec > 4) [1] 0.04213349 0.04317451 ### This is a 99% Confidence Interval ### with point estimate 0.042654 (c) Xmat2 = -cbind(log(1-exp(-Xmat[,1])), Xmat[,2:3]) Xvec2 = c(Xmat2 %*% rep(1,3)) > 0.5*(mean(Xvec>4) + mean(Xvec2>4)) [1] 0.042587 ### Estimated standard error: > cor(Xvec>4, Xvec2>4) [1] -0.04445675 ### not very negative, so not much saving ### as compared with just averaging with another 1e6 deviates > sqrt(0.5*(1-0.04445675)) [1] 0.6912103 ## factor by which the CI based on averaged data will be smaller ## New CI: 0.042587 + (qnorm(.995)/1.e3)*c(-1,1)*sd(Xvec>4)*0.69121 [1] 0.04222722 0.04294678 (d) Control-variates method: > summary(lm(I(Xvec>4) ~ I(Xvec-1)))$coef Estimate Std. Error t value Pr(>|t|) (Intercept) 0.04269797 0.0001722210 247.9254 0 I(Xvec - 1) 0.06461778 0.0001052741 613.8051 0 ### So here the CI is > 0.04269797 + qnorm(.995)*c(-1,1)*0.0001722210 [1] 0.04225436 0.04314158 ### NOTE that the true answer is actually right at the lower end of ### all of these confidence intervals !! ### Repeating the same simulation again, with independent numbers, gives: (b) 0.04168811 0.04272389 (c) 0.04188546 0.04260154 (d) 0.04180288 0.04268732