# Travis: Segment 39

### 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 ratio of <math>q</math>'s that goes into 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>?**

<math> q(x2|x1) = </math>

0 | 1 | 0 | 0 | 0 |

0.5 | 0 | 0.5 | 0 | 0 |

0 | 0.5 | 0 | 0.5 | 0 |

0 | 0 | 0.5 | 0 | 0.5 |

0 | 0 | 0 | 1 | 0 |

and <math> q(x1|x2) = q(x2|x1)^{T} </math>

So, the ratio of q's is just the element wise division of <math> \frac{q(x1|x2)}{q(x2|x1)} = \frac{q(x1|x2)}{q(x1|x2)^T} </math> which is

0 | 2 | 0 | 0 | 0 |

0.5 | 0 | 1 | 0 | 0 |

0 | 1 | 0 | 1 | 0 |

0 | 0 | 1 | 0 | 0.5 |

0 | 0 | 0 | 1 | 0 |

**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 ratio of <math>q</math>'s that goes into the acceptance probability <math>\alpha(x_1,x_2)</math>.**

### To Think About

**1. Suppose an urn contains 7 large orange balls, 3 medium purple balls, and 5 small green balls. When balls are drawn randomly, the larger ones are more likely to be drawn, in the proportions large:medium:small = 6:4:3. You want to draw exactly 6 balls, one at a time without replacement. How would you use Gibbs sampling to learn: (a) How often do you get 4 orange plus 2 of the same (non-orange) color? (b) What is the expectation (mean) of the product of the number of purple and number of green balls drawn?**

**2. How would you do the same problem computationally but without Gibbs sampling?**

**3. How would you do the same problem non-stochastically (e.g., obtain answers to 12 significant figures)? (Hint: This is known as the Wallenius non-central hypergeometric distribution.)**

[Answers: 0.155342 and 1.34699]