# Noninformative prior for variance, understanding and coding

I have three questions regarding the understanding behind and implementation of a noninformative prior for variance. I'm attempting to build a Metropolis sampler and I'm trying to sample from a noninformative prior for variance. From most texts I've consulted, the noninformative prior for variance $\sigma^2$ is given as $p(\sigma^2) \propto 1/\sigma^2$. One book states that you first assign a uniform prior to $log(\sigma^2)$, so (1st question) is this saying that $p(log(\sigma^2)) \propto 1$? Second, the book says to transform the uniform prior on $log(\sigma^2)$ into a density for $\sigma^2$, since doing so will give $p(\sigma^2) \propto 1/\sigma^2$. (2nd Question) I'm lost as to how they went from the uniform prior on $log(\sigma^2)$ to $p(\sigma^2) \propto 1/\sigma^2$ and was hoping someone could explain this. Finally (3rd question), if I were to sample from the density $p(\sigma^2)$, how exactly do I do this? That is, if I were going to code this in MATLAB would I sample from a uniform distribution and take its reciprocal as a sample for $\sigma^2$ (something like sigma_sq = 1/rand;)? Thanks!

• you can't simulate from the prior $1/\sigma^2$ because that's not a density. However, in MCMC you do not simulate from the prior but from the proposal or the conditionals when it is a Gibbs sapling. I suggest you to read carefully your book. – utobi Jun 25 '15 at 19:14
• Note that the "uniform" prior on $log(\sigma^2)$ is over the whole support of $\log(sigma^2)$, i.e. the whole real line, whereas rand is uniform over the interval (0,1). – jaradniemi Jun 25 '15 at 20:19