Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
odunbar committed Oct 1, 2022
1 parent 64d91c5 commit b0ab975
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/MarkovChainMonteCarlo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,23 @@ function EmulatorPosteriorModel(
) where {FT <: AbstractFloat}
return AdvancedMH.DensityModel(
function (θ)
# θ: model params we evaluate at; in original coords.
# transform_to_real = false means g, g_cov, obs_sample are in decorrelated coords.
#
# Recall predict() written to return multiple N_samples: expects input to be a
# Matrix with N_samples columns. Returned g is likewise a Matrix, and g_cov is a
# Vector of N_samples covariance matrices. For MH, N_samples is always 1, so we
# have to reshape()/re-cast input/output; simpler to do here than add a
# predict() method.
g, g_cov = Emulators.predict(em, reshape(θ, :, 1), transform_to_real = false)
if isa(g_cov[1],Real)
return logpdf(MvNormal(obs_sample, g_cov[1]*I), vec(g)) + get_logpdf(prior, θ)
else
return logpdf(MvNormal(obs_sample, g_cov[1]), vec(g)) + get_logpdf(prior, θ)
end

end)
# θ: model params we evaluate at; in original coords.
# transform_to_real = false means g, g_cov, obs_sample are in decorrelated coords.
#
# Recall predict() written to return multiple N_samples: expects input to be a
# Matrix with N_samples columns. Returned g is likewise a Matrix, and g_cov is a
# Vector of N_samples covariance matrices. For MH, N_samples is always 1, so we
# have to reshape()/re-cast input/output; simpler to do here than add a
# predict() method.
g, g_cov = Emulators.predict(em, reshape(θ, :, 1), transform_to_real = false)
if isa(g_cov[1], Real)
return logpdf(MvNormal(obs_sample, g_cov[1] * I), vec(g)) + get_logpdf(prior, θ)
else
return logpdf(MvNormal(obs_sample, g_cov[1]), vec(g)) + get_logpdf(prior, θ)
end

end,
)
end

# ------------------------------------------------------------------------------------------
Expand Down

0 comments on commit b0ab975

Please sign in to comment.