diff --git a/src/MarkovChainMonteCarlo.jl b/src/MarkovChainMonteCarlo.jl index 0ebb0abf..00629066 100644 --- a/src/MarkovChainMonteCarlo.jl +++ b/src/MarkovChainMonteCarlo.jl @@ -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 # ------------------------------------------------------------------------------------------