问题描述
我运行了 Gibbs 采样器并获得了 $X_1$ 和 $X_2$ 的样本。我正在尝试重新创建这样的情节:
如何在 R 上重新创建步行部分?
解决方法
我能想到的最直接的重新创建步行部分的方法是这样的:
x = c(0)
for(i in 2:100){
x[i] = x[i-1] + floor(runif(1,-5,5))
}
pdf(file = "My Plot.pdf",width = 4,height = 4)
plot(x,type="l")
dev.off()
观察:我做了一个简单的步行
结果是这样的: