Skip to content

Commit 7529539

Browse files
committed
BUG Fix example to use new trailing underscore for transformed variables.
1 parent f622419 commit 7529539

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

pymc3/examples/discrete_find_MAP.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040

4141
with model:
4242
for i in range(n+1):
43-
s = {'p_logodds': 0.5, 'surv_sim': i}
43+
s = {'p_logodds_': 0.5, 'surv_sim': i}
4444
map_est = mc.find_MAP(start=s, vars=model.vars,
4545
fmin=mc.starting.optimize.fmin_bfgs)
4646
print('surv_sim: %i->%i, p: %f->%f, LogP:%f'%(s['surv_sim'],
4747
map_est['surv_sim'],
48-
s['p_logodds'],
49-
map_est['p_logodds'],
48+
s['p_logodds_'],
49+
map_est['p_logodds_'],
5050
model.logp(map_est)))
5151

5252
# Once again because the gradient of `surv_sim` provides no information to the
@@ -58,12 +58,12 @@
5858

5959
with model:
6060
for i in range(n+1):
61-
s = {'p_logodds': 0.0, 'surv_sim': i}
61+
s = {'p_logodds_': 0.0, 'surv_sim': i}
6262
map_est = mc.find_MAP(start=s, vars=model.vars)
6363
print('surv_sim: %i->%i, p: %f->%f, LogP:%f'%(s['surv_sim'],
6464
map_est['surv_sim'],
65-
s['p_logodds'],
66-
map_est['p_logodds'],
65+
s['p_logodds_'],
66+
map_est['p_logodds_'],
6767
model.logp(map_est)))
6868

6969
# For most starting values this converges to the maximum log likelihood of
@@ -82,12 +82,12 @@ def bh(*args, **kwargs):
8282

8383
with model:
8484
for i in range(n+1):
85-
s = {'p_logodds': 0.0, 'surv_sim': i}
85+
s = {'p_logodds_': 0.0, 'surv_sim': i}
8686
map_est = mc.find_MAP(start=s, vars=model.vars, fmin=bh)
8787
print('surv_sim: %i->%i, p: %f->%f, LogP:%f'%(s['surv_sim'],
8888
map_est['surv_sim'],
89-
s['p_logodds'],
90-
map_est['p_logodds'],
89+
s['p_logodds_'],
90+
map_est['p_logodds_'],
9191
model.logp(map_est)))
9292

9393
# By default `basinhopping` uses a gradient minimization technique,
@@ -96,13 +96,13 @@ def bh(*args, **kwargs):
9696

9797
with model:
9898
for i in range(n+1):
99-
s = {'p_logodds': 0.0, 'surv_sim': i}
99+
s = {'p_logodds_': 0.0, 'surv_sim': i}
100100
map_est = mc.find_MAP(start=s, vars=model.vars,
101101
fmin=bh, minimizer_kwargs={"method": "Powell"})
102102
print('surv_sim: %i->%i, p: %f->%f, LogP:%f'%(s['surv_sim'],
103103
map_est['surv_sim'],
104-
s['p_logodds'],
105-
map_est['p_logodds'],
104+
s['p_logodds_'],
105+
map_est['p_logodds_'],
106106
model.logp(map_est)))
107107

108108
# Confident in our MAP estimate we can sample from the posterior, making sure

0 commit comments

Comments
 (0)