Skip to content

Commit fb8d38b

Browse files
ricardoV94twiecki
authored andcommitted
Fix BinaryMetropolis astep
1 parent 5bdfdde commit fb8d38b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pymc3/step_methods/metropolis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def __init__(self, vars, scaling=1.0, tune=True, tune_interval=100, model=None):
329329

330330
def astep(self, q0: RaveledVars, logp) -> Tuple[RaveledVars, List[Dict[str, Any]]]:
331331

332+
logp_q0 = logp(q0)
332333
point_map_info = q0.point_map_info
333334
q0 = q0.data
334335

@@ -340,8 +341,9 @@ def astep(self, q0: RaveledVars, logp) -> Tuple[RaveledVars, List[Dict[str, Any]
340341
# Locations where switches occur, according to p_jump
341342
switch_locs = rand_array < p_jump
342343
q[switch_locs] = True - q[switch_locs]
344+
logp_q = logp(RaveledVars(q, point_map_info))
343345

344-
accept = logp(q) - logp(q0)
346+
accept = logp_q - logp_q0
345347
q_new, accepted = metrop_select(accept, q, q0)
346348
self.accepted += accepted
347349

0 commit comments

Comments
 (0)