Skip to content

log_sum_exp and log_diff_exp boundaries #646

@bob-carpenter

Description

@bob-carpenter

Summary:

The boundary conditions are off for negative infinite values. Currently, we have

log_sum_exp(log(0), log(0)) = nan
log_diff_exp(log(0), log(0)) = nan
log_diff_exp(log(1), log(1)) = nan

and they should all return negative infinity. For example,

log_sum_exp(log(0), log(0))
  = log_sum_exp(-inf, -inf)
  = log(exp(-inf) + exp(-inf))
  = log(0 + 0)
  = -inf

Now some care is going to have to be taken to manage the derivatives. We may not be able to chain rule through the resulting negative infinities for an expression like exp(log_sum_exp(log(0), log(0))). The more doc explaining what's going on in the math lib (and Stan doc itself), the better.

Originally reported by Dalton Hance on Discourse:

http://discourse.mc-stan.org/t/log-0-and-stan-arithmetic/2171

Current Version:

v2.17.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions