Skip to content

Commit 8bd7837

Browse files
Add minor formatting, such as periods after equations.
1 parent 3fea175 commit 8bd7837

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contents/metropolis/metropolis.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ To understand how this works, let's call $$x_t$$ the position before the step, a
120120
We then define the probability of __accepting the step__ to be
121121

122122
$$
123-
A = \min \left(\frac{f(x')}{f(x_t)}, 1\right)
123+
A = \min \left(\frac{f(x')}{f(x_t)}, 1\right).
124124
$$
125125

126126
The $$\min$$ function above implies that $$A=1$$ if $$f(x') \gt f(x_t)$$, which means that the move will __always__ be accepted if it is toward a higher probability position.
@@ -148,12 +148,12 @@ And if global sampling is the goal, the process of exploration could be sped up
148148

149149
Let our target distribution be
150150
$$
151-
P(x) = \frac{f(x)}{\int_{-10}^{10} f(x)}
151+
P(x) = \frac{f(x)}{\int_{-10}^{10} f(x)},
152152
$$
153153

154154
where $$f(x)$$ is the function we know and is given by
155155
$$
156-
f(x) = 10e^{-4(x+4)^2} + 3e^{-0.2(x+1)^2} + e^{-2(x-5)^2}
156+
f(x) = 10e^{-4(x+4)^2} + 3e^{-0.2(x+1)^2} + e^{-2(x-5)^2}.
157157
$$
158158

159159
The code for defining this function is given below.
@@ -205,15 +205,15 @@ We just need to choose the domain of $$x$$, and an initial point for $$ x_0 $$ (
205205

206206
### How to Iterate
207207

208-
1. Generate new proposed position $$x' = x_t + g$$
208+
1. Generate new proposed position $$x' = x_t + g$$.
209209
2. Calculate the acceptance probability,
210210
$$
211-
A = \min\left(1, \frac{f(x')}{f(x_t)}\right)
211+
A = \min\left(1, \frac{f(x')}{f(x_t)}\right).
212212
$$
213213
3. Accept proposal, $$x'$$ with probability $$A$$. If your programming language doesn't have a built-in method for this,
214214
* Generate a random number $$u$$ between $$0$$ and $$1$$.
215-
* If $$ u \leq A $$, then __accept__ move, and set new position, $$x_{t+1} = x' $$
216-
* Otherwise, __reject__ move, and set new position to current, $$x_{t+1} = x_t $$
215+
* If $$ u \leq A $$, then __accept__ move, and set new position, $$x_{t+1} = x' $$.
216+
* Otherwise, __reject__ move, and set new position to current, $$x_{t+1} = x_t $$.
217217
4. Increment $$t \rightarrow t + 1$$ and repeat from step 1.
218218

219219
The code for steps 1 to 3 is:

0 commit comments

Comments
 (0)