Bob Carpenter
unread,Jul 8, 2012, 4:07:12 PM7/8/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to stan...@googlegroups.com
As is, when a variable is declared in Stan with
range (0,inf), a log transform is applied to unconstrain
it. In practice, this means we inverse transform it using
the exponential function. This is costly computationally.
Instead, we could use a transform f : (0,inf) -> (-inf,inf)
for some lower bound epsilon > 0 with
f(x) = log x + (1 - log epsilon) if x < epsilon, and
= x / epsilon if x >= epsilon.
Then the inverse function g : (-inf,inf) -> (0,inf) would be
g(y) = exp(y) - (espilon - log epsilon) if y < log epsilon, and
= epsilon * y if y >= log epsilon.
The function g(y) is continuous and differentiable everywhere with
g'(y) = exp(y) if y < log epsilon
= epsilon if y >= log epsilon
leading to log Jacobian
log | g'(y) | = y if y < log epsilon, and
= log epsilon if y >= log epsilon.
This will lead to faster transforms and fewer derivative terms
on the auto-dif stack. It also prevents overflow as y -> inf.
I'm not clear on whether this will be a good or bad thing
geometry-wise for HMC.
- Bob