Stefan:

Ok so maybe that wasn't the best example to illustrate the Float64 issue. I 
guess using the parametric types in functions works so solve this (but not the 
push! issue)

function chaininit{T}(theta_init::Vector{T}, n)
        chain = Array{T,1}[theta_init]
        for k=1:n
               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
        chain
end
function chainadd!{T}(chain::Vector{Vector{T}}, n)
        for k=1:n
               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
end


Reply via email to