Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
AbstractGPs = "0.5.21"
AbstractMCMC = "3.3, 4, 5"
AdvancedMH = "0.6, 0.7, 0.8"
AbstractMCMC = "5"
AdvancedMH = "0.8"
ChunkSplitters = "3.1.2"
Conda = "1.7"
Distributions = "0.24, 0.25"
DocStringExtensions = "0.8, 0.9"
EnsembleKalmanProcesses = "2"
ForwardDiff = "0.10.38, 1"
ForwardDiff = "1"
GaussianProcesses = "0.12"
KernelFunctions = "0.10.64"
MCMCChains = "4.14, 5, 6, 7"
MCMCChains = "7"
Printf = "1"
ProgressBars = "1"
PyCall = "1.93"
Expand Down
13 changes: 9 additions & 4 deletions src/MarkovChainMonteCarlo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,14 @@ function AbstractMCMC.step(
new_params = AdvancedMH.propose(rng, sampler, model, current_state; stepsize = stepsize)
# Calculate the log acceptance probability and the log density of the candidate.
new_log_density = AdvancedMH.logdensity(model, new_params)

# Just to initialize: if you pass state, it just reads the old log_density (initialized as false). in this case, compute it by passing the actual parameter values
current_log_density =
isa(AdvancedMH.logdensity(model, current_state), Bool) ? AdvancedMH.logdensity(model, current_state.params) :
AdvancedMH.logdensity(model, current_state)

log_α =
new_log_density - AdvancedMH.logdensity(model, current_state) +
AdvancedMH.logratio_proposal_density(sampler, current_state, new_params)
new_log_density - current_log_density + AdvancedMH.logratio_proposal_density(sampler, current_state, new_params)

# Decide whether to return the previous params or the new one.
new_state = if -Random.randexp(rng) < log_α
Expand Down Expand Up @@ -573,7 +578,7 @@ function MCMCWrapper(
end

sample_kwargs = (; # set defaults here
:init_params => deepcopy(init_params),
:initial_params => deepcopy(init_params),
:param_names => param_names,
:discard_initial => burnin,
:chain_type => MCMCChains.Chains,
Expand Down Expand Up @@ -641,7 +646,7 @@ end

function _find_mcmc_step_log(mcmc::MCMCWrapper)
str_ = @sprintf "%d starting params:" 0
for p in zip(mcmc.sample_kwargs.param_names, mcmc.sample_kwargs.init_params)
for p in zip(mcmc.sample_kwargs.param_names, mcmc.sample_kwargs.initial_params)
str_ *= @sprintf " %s: %.3g" p[1] p[2]
end
println(str_)
Expand Down