Is there an inverse / reciprocal / log-uniform distribution in PyMC?

Many sources mention the non-informative prior 1/x, which is uniform on the log scale. This seems to be called the inverse, reciprocal, or log-uniform distribution, but I find no mention of this in either the PyMC or STAN documentations. It is trivial to add it as a Potential, but then it cannot be prior-post sampled from. Am I missing it somewhere?

You can just use tt.exp(pm.Flat("logval")).
This is an improper prior just like Flat, so you can’t sample from it by definition.
I wouldn’t usually recommend using this prior unless you have good reason to. It assumes that your problem is perfectly scale invariant, which I would argue is usually not the case.
A half normal or half student-t is in most settings a better prior for scale parameters.

1 Like

I know that the unbounded distribution is improper, but it can be given bounds, like the Uniform to make it proper.

Thanks for the tip though!

In that case it would be tt.exp(pm.Uniform('logval', lower=-1, upper=3)).
But really, don’t do that unless you really know that you need this. This is definitely not best practice.