Similar question to posted here: Metropolis-Hastings using log of the density however my question is around sampling a random number from a uniform distribution. I am following the steps outlined in Murphy: Machine Learning A Probabilistic Perspective on page 850 for Metropolis Hastings algorithm. The difference is I am working with log probability densities as they are large and negative, so exponentiating them effecitvely results in 0.
I have started by taking the log of step 5: $$ log(\alpha) = log(P(x')) - log(P(x)) $$ Assuming q is symmetric which it is in my case. Then to compute $r$, I am taking the lesser of $log(1)$ and $log(\alpha)$, so essentially if $\alpha$ is negative, I am assigning it to $r$, otherwise I am assigning $r$ as 0. Now for the issue: what do I do at step 6? The link above doesn't describe this. Obviously $r$ is either 0 or negative, and so it would always be less than $u$ and hence we always step where we are. Also, $r$ isn't bounded below - $\alpha$ could be very negative (though unlikely), so it is hard to redefine a uniform distribution range to sample from. Any ideas how to proceed from here?
min
step is unnecessary for the comparison. $\endgroup$