-
-
Notifications
You must be signed in to change notification settings - Fork 228
Description
Describe the bug 🐞
Suppose you have 4 ODE parameters and for each one, there is a prior assigned:
invpriors= [
Normal(1, 2),
Normal(2, 2),
Normal(2, 2),
Normal(0, 2)]
Also suppose you have a vector of parameters θ = [weights..., biases..., λ1, λ2, λ3, λ4] where λ1, λ2, λ3, λ4 are parameter values of the ODE system. The function priorweights() on line 247 of advancedHMC_MCMC.jl evaluates the log PDF at these parameter values:
invlogpdf = sum(
logpdf(invpriors[length(θ) - i + 1], θ[i])
for i in (length(θ) - ltd.extraparams + 1):length(θ))
Except the indices are incorrect. Unrolled, this will evaluate param[4](λ1), param[3](λ2), param[2](λ3) and param[1](λ4). In many cases this is probably not a big deal, but still could be fixed quickly.
Expected behavior
Should evaluate param[1](λ1), param[2](λ2), param[3](λ3) and param[4](λ4). The fix seems easy: Replace
logpdf(invpriors[length(θ) - i + 1], θ[i])
with
logpdf(invpriors[i - length(θ) + ltd.extraparams], θ[i])
or some other cleaner version. Is this worth fixing? Happy to submit a quick PR.