I've run a Gibbs sampler and obtained a sample for $X_1$ and $X_2$. I'm trying to recreate a plot like this one:
How do I recreate the walk part on R?
I've run a Gibbs sampler and obtained a sample for $X_1$ and $X_2$. I'm trying to recreate a plot like this one:
How do I recreate the walk part on R?
The most straightforward way I can think of to recreate the walk part would be like this:
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()
Obs.: I made up a simple walk
The result was this one: