/Segment39

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

To Calculate

1. Suppose the domain of a model are the five integers <math>x = \{1,2,3,4,5\}</math>, and that your proposal distribution is: "When <math>x_1 = 2,3,4</math>, choose with equal probability <math>x_2 = x_1 \pm 1</math>. For <math>x_1=1</math> always choose <math>x_2 =2</math>. For <math>x_1=5</math> always choose <math>x_2 =4</math>. What is the acceptance probability <math>\alpha(x_1,x_2)</math> for all the possible values of <math>x_1</math> and <math>x_2</math>?

Matricesx1x2.png


2. Suppose the domain of a model is <math>-\infty < x < \infty</math> and your proposal distribution is (perversely),

<math>q(x_2|x_1) = \begin{cases}\tfrac{7}{2}\exp[-7(x_2-x_1]),\quad & x_2 \ge x_1 \\ \tfrac{5}{2}\exp[-5(x_1-x_2)],\quad & x_2 < x_1 \end{cases}</math>

Sketch this distribution as a function of <math>x_2-x_1</math>. Then, write down an expression for the acceptance probability <math>\alpha(x_1,x_2)</math>.

Dis.png

Zoom-in view

Dis2.png

import numpy as np
import matplotlib.pyplot as plt
import math

def func(dx21):
    if dx21<0:
        q=5/2*math.exp(5*dx21)
    else:
        q=7/2*math.exp(-7*dx21)
    return q
v=np.arange(-5,5, 0.001)
x=[]
fx=[]
for i in v:
    x.append(i)
    fx.append(func(i))
plt.plot(x, fx)
plt.show()


when <math> x_2 \geq x_1 </math>,

<math> \alpha(x_1, x_2) = min(1, \frac {\pi(x_2)\frac 52 exp(-5(x_1-x_2))}{\pi(x_1) \frac 72 exp(-7(x_2-x_1))} </math>

when <math> x_2 < x_1 </math>,

<math> \alpha(x_1, x_2) = min(1, \frac {\pi(x_2) \frac 72 exp(-7(x_2-x_1))}{\pi(x_1)\frac 52 exp(-5(x_1-x_2))} </math>