Gibbs Sampler Algorithmによって多変量正規分布からのサンプル抽出を行なう

もちろんRで。 2変数正規分布 2変数の正規分布からのサンプリングはここのをそのまままねすると B <- 2000 x1 <- rep(NA,B+1) x2 <- rep(NA,B+1) x1[1] <- -2 x2[1] <- 1 for (i in 1:B){ x1[i+1] <- rnorm(1,1+0.7*(x2[i]-2),sqrt(1-0.7^2)) x2[i+1] <- rno…

俺的MCMCまとめ

12月くらいからMCMCの勉強しだして、いくつか代表的なアルゴリズムによるサンプリングをやったのでまとめておく。 Example of Rejection Sampling - yasuhisa's blog Example of importance sampling - yasuhisa's blog Example of Metropolis Hastings Algo…