#Plotting in preparation for the ImpSamp function. Suggests ideal g* would be an unusual distribution
x=seq(-3,3,by=.1)
gx=sqrt(abs(x/(1-x)))*dt(x,5)
plot(x,gx,type="l")
lines(x,dt(x,5),lty=2,col="red")
lines(x,sqrt(abs(x/(1-x)))/5,lty=3,col="green")
legend(-2,.6,c("h(x)*f(x)","f(x)","Scaled h(x)"),col=c("black","red","green"),lty=c(1,2,3))
上面的小例子是作重要性抽样的R代码,代码摘自:http://www.stat.sc.edu/~grego/courses/stat740/。这个网页上还有很多关于统计计算的资源。作此记录一来是感......
阅读全文