import matplotlib.pyplot as plt
import numpy as np
def _q_x2_given_x1(x2_minus_x1):
if x2_minus_x1 >= 0:
# x2 >= x1
return (7.0 / 2.0) * np.exp(-7 * x2_minus_x1)
else:
# x2 < x1
x1_minus_x2 = -x2_minus_x1
return (5.0 / 2.0) * np.exp(-5 * x1_minus_x2)
q_x2_given_x1 = np.vectorize(_q_x2_given_x1)
Here is the proposal distribution as a function of $x_2 - x_1$:
x_axis = np.linspace(-1, 1, 2000)
y_axis = q_x2_given_x1(x_axis)
plt.plot(x_axis, y_axis)
plt.xlabel('$x_2 - x_1$')
plt.ylabel('$q(x_2 | x_1)$')
<matplotlib.text.Text at 0xa0a0e6c>
And just for fun, the proposal distribution as a function of $x_1$ and $x_2$:
x1, x2 = np.meshgrid(np.linspace(-0.5, 0.5, 1000), np.linspace(-0.5, 0.5, 1000))
q = q_x2_given_x1(x2 - x1)
plt.imshow(q, origin='lower', extent=(-1, 1, -1, 1))
plt.colorbar()
plt.xlabel('$x1$')
plt.ylabel('$x2$')
<matplotlib.text.Text at 0xa366b4c>
It was a little tricky to keep all the $x$'s and different cases straight, so I may have made a mistake. But here's what I got:
$$ \frac{q(x_1 | x_{2c})}{q(x_{2c} | x_1)} = \begin{cases} \tfrac{5}{7}\exp[-2(x_1-x_{2c})],\quad & x_{2c} > x_1 \\ \tfrac{7}{5}\exp[-2(x_1-x_{2c})],\quad & x_{2c} < x_1 \\ 1,\quad & x_{2c} = x_1 \end{cases} $$