log_sum_exp zero-case + tests

15 views
Skip to first unread message

Bob Carpenter

unread,
Mar 22, 2012, 1:19:31 AM3/22/12
to stan...@googlegroups.com
The term

log_sum_exp(0,x)

showed up in the simplex transform when I rearranged
terms to try to prevent overflow.

So I built a special function (and class in auto-dif)
for it. Here's the definition:

log1p_exp(x) = log_sum_exp(0,x)

= log(exp(0) + exp(x))

= log(1 + exp(x))

= log1p(exp(x))

and function signatures:

double stan::math::log1p_exp(double x);

var stan::agrad::log1p_exp(const var& a);

- Bob

Reply all
Reply to author
Forward
0 new messages