1: R ← number of required samples from $_{p}$($_{q}$ | y ) 2: M ← number of proposal draws for estimating ̂ q$_{v}$ ( v ) . 3: q ∗ ← mode of D ($_{q}$ , y ) 4: c$_{1}$ ← D ($_{q}$ $^{∗}$, y ) 5: $_{FLAG}$← TRUE 6: while FLAG do 7: Choose new proposal distribution g ($_{q}$) 8: $_{FLAG}$←$_{FALSE}$ 9: c$_{2}$ ← g ($_{q}$ $^{∗}$) . 10: for m : = 1 to M do 11: Sample q m ∼ g ($_{q}$) . 12: log F ($_{q}$$_{m}$ | y ) ← log D ($_{q}$$_{m}$ , y ) − log g ($_{q}$$_{m}$) − log c$_{1}$ + log c$_{2}$ . 13: v$_{m}$ = − log F ($_{q}$$_{m}$ | y ) 14: if log F ($_{q}$$_{m}$ | y ) > 0 then 15: $_{FLAG}$← TRUE 16: break 17: end if 18: end for 19: end while 20: Reorder elements of v , so 0 < v$_{1}$ < v$_{2}$ < . . . < v$_{M}$ < ¥ . Define v$_{M}$$_{+}$$_{1}$ : = ¥ 21: for i : = 1 to M do 22: ̂ q$_{v}$ ( v$_{i}$ ) ← GLYPH<229> M j = $_{1}$1 $^{[}$v$_{j}$ < v$_{i}$ $^{]}$. 23: v i ← ̂ q$_{v}$ ( v$_{i}$ ) [ exp ( − v$_{i}$ ) − exp ( − v$_{i}$$_{+}$$_{1}$ )] . 24: end for 25: for r = 1 to R do 26: Sample j ∼ Multinomial ($_{v}$$_{1}$ . . . v $_{M}$) . 27: Sample h ∼ Uniform(0,1). 28: v ∗ ← v$_{j}$ − log $^{[}$1 −$_{h}$ $^{(}$1 − exp $^{(}$v$_{j}$ − v$_{j}$$_{+}$$_{1}$ $^{))]}$. 29: p ← 0 30: n$_{r}$ ← 0. {Counter for number of proposals} 31: while p > v ∗ do 32: Sample q r ∼ g ($_{q}$) . 33: p ← − log F ($_{q}$$_{r}$ | y ) . 34: n$_{r}$ ← n$_{r}$ + 1. 35: end while 36: end for 37: return q 1 . . . q R (plus n$_{1}$ . . . n$_{R}$ and v$_{1}$ . . . v$_{M}$ if computing a marginal likelihood). 8 Algorithm 1 Algorithm to collect R samples from $_{p}$($_{q}$ | y )