请在 下方输入 要搜索的题目:

R.V. X~N(mu=0,sig=1), theta=Ee^(-X^2). Estimating theta using a control variate to reduce the variance.

R.V. X~N(mu=0,sig=1), theta=Ee^(-X^2). Estimating theta using a control variate to reduce the variance.

发布时间:2025-03-08 06:20:58
推荐参考答案 ( 由 题搜搜 官方老师解答 )
答案:【计分规则】: rm(list=ls())n<-10000;m<-100;mu=0;sig=1;p=2000#Ex1^2=sig^2+mu^2#pilot simulationx<-rnorm(p,mu,sig)y<-exp(-x^2)f<-function(x)exp(-x^2-(x-mu)^2/(2*sig^2))/(sqrt(2*pi)*sig)#tm=integrate(f,-100,100)tm=exp(-mu^2/(1+2*sig^2))/sqrt(1+2*sig^2)#close formulaz<-x^2;#control variateastar<-cov(y,z)/var(z)#main simulationx1<-rnorm(n*m,mu,sig)y<-exp(-x1^2)z<-x1^2v<-y-astar*(z-mu^2-sig^2)var(y)var(v)dim(y)=c(n,m)dim(v)=c(n,m)mu1<-colMeans(y)mu2<-colMeans(v)plot(mu1,type='o',col='blue')points(mu2,pch='*',col='red')abline(h=tm,lty=2,lwd=3,col='green')legend('topright',c('no vrt','with vrt','true'),col=c('blue','red','green'),lty=c(0,0,2),lwd=c(0,0,3),pch=c('o','*','-'))
登录 - 搜搜题库网
立即注册
注册 - 搜搜题库网
立即登录