Ok, here is quickest example that I came up with.
theta_init = [2.0, 3.0, 4.0]
chain = Array{Float64,1}[init]
for k=1:10_000
theta_prop = chain[end]
theta_prop += rand(3)
likelihoodratio = computelr(theta_prop, theta_curr)
if rand() < minimum([1,likelihoodratio])
push!(chain, theta_prop)
else
push!(chain, theta_curr)
end
end
I'm generating a markov chain of vectors. The code proposes a new state vector,
theta_prop, and pushes it to chain if it satisfies a criterion. The problem is
that I may run it for 10_000 steps, look at the results and then decide to run
it for longer... so preinitializing isn't as natural.
BTW: thanks a ton...I can't believe I'm having Stefan look at my code!