3. Tail Moments of the Standard Normal Distribution, Revisited. In the last HW,
ID: 3207572 • Letter: 3
Question
3. Tail Moments of the Standard Normal Distribution, Revisited. In the last HW, you estimated the conditional moment of the standard normal distribution: Z N (0,1) EZIZ using Monte Carlo. Now you will do the same using importance sampling (a) First, use the efficient sampler you wrote in your last HW (or use the one in the posted solutions) to estimate 0.5 using Monte Carlo with 1,000 MC samples. Report the estimate 0.1.5, the time it took to compute the estimator (most of this time will be spent drawing the ZIZ a), and your standard error (b) Now you will estimate 04.5 using an importance sampler. First, use a N(u, or as your proposal distribution. Show to to write the expectation 01.5 as an expectation with respect to the N(,o distribution (c) Write the density of ZIZ a in terms of the normal pdf and the normal cdf. Implement this density as an R function. Use your function to plot this density for enough values of between -1 and 10 to make the plot look smooth (d) Implement an importance sampler using a N(u, o2) as the proposal density. Again, use 1,000 samples. Estimate 64.5 using your importance sampler for a few different values of u and o and calculate the standard error. For the best values of hu and o2 that you find, plot the corresponding density on top of your plot of the density of ZIZ a, and report 04.5 how long it took to compute the estimator, and the standard error (e) Now try a different proposal density. rite another importance sampler that uses an Eap(A a proposal density. Run your new importance sampler using 1,000 samples, and report 4.5 how long it took to compute the estimator, and the standard error (f) Make a table that summarizes your three estimators of 04.5. This table should contain the point estimate, the running time, and the standard error. Which estimator to you think is the best?Explanation / Answer
---------------------------------b-----------------------------------
fun.b=function(n,mu,sigma,alpha)
{
normal=rnorm(n,mu,sigma)
tnormal=normal[normal>alpha]
return(mean(tnormal))
}
fun.b(10010,5,1,4.5)
------------------------------------------------c--------------------------------------------------------
install.packages("msm")
library(msm)
fun.c=function(n,mu,sigma,alpha)
{
x=rtnorm(n,mu,sigma,lower=alpha)
return(plot(density(x,na.rm = TRUE,bw=.2),xlim=c(-1,10)))
}
fun.c(100,5,1,4.5)
-----------------------------------------------d-----------------------------------------------
normal=0
tnormal=0
fun.d=function(n,mu,sigma,alpha)
{
normal=matrix(c(0,0),n,4)
mu=seq(mu-1,mu+1,.5)
sigma=seq(sigma/2,sigma*2,.5)
par(mfrow=c(2,2))
for(j in 1:4)
{
normal[,j]=rtnorm(1,mu[j],sigma[j],alpha)
plot(density(normal[,j],na.rm = TRUE,bw=.2))
}
return(normal)
}
sd(normal[,1])
sd(normal[,2])
sd(normal[,3])
sd(normal[,4])
## which sd is minimum will take that sample mean and sd as the best choice.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.