log_sum: Compute the log of the sum of values given as logs

Description Usage Arguments Details Value

View source: R/waic.R

Description

Compute log(sum(exp(x))), but do so in a way that avoids underflow.

Usage

1
log_sum(lx)

Arguments

lx

Vector of logs

Details

Use the following identity to stabilize the calculation:

∑ \exp(x-x_0) = 1/x0 ∑ \exp(x)

Value

log of the sum of the antilogs of the input values.


JGCRI/gcamland documentation built on Oct. 6, 2020, 5:30 p.m.