Stan's default uniform priors

#1

When we say that, in Stan, parameters are given uniform priors when otherwise unspecified, is this equivalent to saying that each of the discrete possible floating point numbers is given equal probability? This could be weird, as apparently half of single-precision[0] floating point numbers are in the [-1, 1] interval.

[0] I realize we use double-precision but I assume there are similarly weird things happening there.

#2

It is not equivalent. The priors work independently of the particular floating point implementation (otherwise all of Stanâ€™s results and those of similar software would probably be biased). With â€śall valuesâ€ť we mean, mathematically, all real values. Because a prior with equal weight for all real values cannot yield a distribution which integrates to 1, this is an improper prior.

#3

Do you know how thatâ€™s implemented? I am new in this area and having trouble imagining how that would work; from a naive outside perspective it seems like the default is â€śuniformâ€ť because it doesnâ€™t modify the target lpdf at all for any given parameter value without a distributional statement attached. But this would be equivalent to saying all floating point numbers have equivalent probability, which runs into some of the issues in the link above (though presumably itâ€™s not quite as bad as that, as we likely donâ€™t use more than 1 FP representation of any given number, avoiding the issue they talk about where there are e.g. 257 ways to represent the number 0.5).

#4

Just keep in mind that random variables in HMC are sampled by integrating a bunch of ODEs around in parameter space, not by actually assigning probabilities to individual outcomes and sampling them. So uniform is not the same as saying all floating point values have equal probability. Same sorta thing for Metropolis but the jumps are different.

#5

I donâ€™t think there is any (working) implementation of probabilitic algorithms assigning probabilities to individual floating points numbers. If this was true, all continuous distributions would be biased towards areas with high density of floating points numbers.

#6

This is a great point - I think all parameter values are given equal probability, but because these candidate parameter values are generated by a process that isnâ€™t affected by the density issues of floating point numbers, everything comes out as if it were continuous uniform.

#7

@seantalts yeah I think thatâ€™s right. It definitely does not imply a discrete uniform distribution over the floating point numbers representable on a computer. But I can totally see why it would seem to imply that. And Iâ€™m surprised that question hasnâ€™t come up more. I guess itâ€™s probably because you need a background in computers for it to even occur to you to that itâ€™s something worth wondering about!

#8

Thinking about what continuous density that would approximate is a good way to start thinking about Jacobians :-)

No. Theyâ€™re all given equal density. You need to integrate density to get back to probability. What happens is that every interval of the same width has the same probability in a simple upper or lower-bounded or unconstrained distribution. But if you do that with a non-compact set of \mathbb{R}^N, things blow up, so probability and density arenâ€™t properly defined. But we just act as if they were and continue (hoping the posterior will be proper after seeing some data).

So if you do something like

real<lower = 0, upper = 1> sigma;

thatâ€™s fine, because \int_0^1 c \, \mathrm{d}\sigma = c. But if we do this,

real<lower = 0> sigma;

we run into problems because \int_0^{\infty} c \, \mathrm{d}\sigma= \infty. So thatâ€™s why itâ€™s â€śimproperâ€ť.

Correct, not affected by density of floating point numbers other than in terms of precision. Thereâ€™s much higher precision in a small neighborhood around 0 than the same sized neighborhood around 1, for example.