On 1/22/13 4:26 AM, Ilya Esteban wrote:
> Just out of curiosity -- given that it takes two lines of code to transform the uniform distribution into the Cauchy, is
> there any particular reason why the built-in Cauchy function is implemented differently and is so much slower?
The problem isn't that Stan's Cauchy density is inefficiently
implemented. It's the geometry, as determined (to second order)
by the Hessian of the log probability of the unconstrained
parameters. (Any parameters declared with constraints are
automatically transformed to unconstrained parameters so HMC
can operate with unconstrained support; the details of the
specific transforms are in the manual toward the back.)
By declaring a uniform variable with constraint that it be
between 0 and 1, then transforming it to a Cauchy implies
a different geometry than defining a Cauchy over an unconstrained
parameter. It's not clear this particular transform will even
help. Of course, there are then other ways to do the [0,1]
transform including inverse CDFs.
The reason he built-in Cauchy function can't do transforms
automatically is that it has no idea what the user's intent
is for the log probability function!
As we learn more about how the geometry affects sampling and which
numerical issues come up, we will hopefully be able to provide
pre-packaged solutions that aren't as clunky as defining
transforms.
Another thing we could do is perform variable transformations
under the hood. That's effectively what we're doing for
parameters declared with constraints. But I'd prefer to keep
things as direct as possible.
- Bob
> --
>
>