Skip to content

Commit

Permalink
Fix the computation of the trajectory weight
Browse files Browse the repository at this point in the history
  • Loading branch information
rlouf committed May 19, 2022
1 parent 18f0e7b commit ede3f37
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions aehmc/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,16 @@ def expand_once(
# the states explored during the final expansion.
acceptance_probability = at.exp(new_proposal[3]) / subtrajectory_length

# Update the proposal.
# If the termination criterion is reached in the subtree or if a
# divergence occurs we reject this subtree's proposal. We
# nevertheless update the sum of the logarithm of the acceptance
# probabilities to serve as an estimate for dual averaging.
updated_weight = at.logaddexp(proposal[2], new_proposal[2])
# Update the proposal
#
# We do not accept proposals that come from diverging or turning subtrajectories.
# However the definition of the acceptance probability is such that the
# acceptance probability needs to be computed across the entire trajectory.
updated_proposal = (
proposal[0],
proposal[1],
updated_weight,
new_proposal[3] + proposal[3],
proposal[2],
at.logaddexp(new_proposal[3], proposal[3]),
)

sampled_proposal = where_proposal(
Expand Down

0 comments on commit ede3f37

Please sign in to comment.