I am trying some exercises from my textbook regarding MCMC and I am having trouble using Metropolis-Hastings algorithm.

If I am trying to sample from a binomial distribution with parameters n and p using a proposal uniform distribution on $\{0,1,...,n\}$

I understand how the Metropolis-Hastings work but I'm having a hard time trying to set up a transition matrix for this binomial distribution.

Since the stationary distribution of the sample $\pi$ would be uniformly distributed, then

\begin{align} a(i,j)=\frac{T_{ji}}{T_{ij}} \end{align}

How can I find each $T_{ji}$? I think that I should be using the pmf of the binomial distribution: $\binom{n}{i}p^i(1-p)^{n-i}$ but I'm not quite sure how to reason this out.

Any help or tips would be greatly appreciated!

  • $\begingroup$ The state space for a binomial distribution is discrete, so how/why do you expect to move around it by using a continuous uniform distribution? $\endgroup$ Apr 2, 2018 at 3:32
  • $\begingroup$ @spaceisdarkgreen well I meant that my uniform distribution is discrete here - is my notation wrong for writing it like that? $\endgroup$
    – Rigel
    Apr 2, 2018 at 3:37
  • $\begingroup$ $U(0,1)$ means the uniform distribution on the interval $(0,1).$ Do you want the proposed transition to be to any number $\{0,1,\ldots n\}$ with equal probability? This would be the uniform distribution on $\{0,1,\ldots, n\}$ $\endgroup$ Apr 2, 2018 at 3:42
  • $\begingroup$ Yes that is what I meant - I'll change my post now $\endgroup$
    – Rigel
    Apr 2, 2018 at 3:51
  • $\begingroup$ You should also be aware that notation is not uniform from source to source on this subjection, so when you ask questions about certain quantities, you should say what they are (like $a(i,j)$ and $T_{ij}$ here). I would assume $a(i,j)$ is the Metropolis acceptance threshold for transitioning from state $j$ to $i$ (or is it $i$ to $j$?) ... see what I mean? $\endgroup$ Apr 2, 2018 at 4:16

1 Answer 1


I will use the notation from wikipedia.

$A(x'\mid x),$ the Metropolis acceptance probability for transitioning from state $x$ to $x',$ is given by $$ A(x'\mid x)= \min\left(\frac{P(x')g(x\mid x')}{P(x)g(x'\mid x)},1\right)$$ where $P(x)$ is the desired distribution and $g(x'\mid x)$ is your probability of proposing $x'$ when the current state is $x.$ You have chosen a $g$ (the uniform distribution) that is symmetric in $x$ and $x',$ so it cancels out and we have $$ A(x'\mid x)= \min\left(\frac{P(x')}{P(x)},1\right).$$

For the binomial $(n,p)$ distribution we have $$ P(x) = {n\choose x}p^x(1-p)^{n-x}$$ so we have an acceptance threshold of $$ \frac{P(x')}{P(x)} = \frac{{n\choose x'}p^{x'}(1-p)^{n-x'}}{{n\choose x}p^x(1-p)^{n-x}}= \frac{(x')!(n-x')!}{x!(n-x)!}\left(\frac{p}{1-p}\right)^{x'-x}$$

  • $\begingroup$ Ah! This notation makes so much more sense to me! Thanks a ton $\endgroup$
    – Rigel
    Apr 2, 2018 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .