Learn R Programming

GSNA (version 0.1.4.2)

lse: lse

Description

Implements the "Log-Sum-Exponential trick" for calculating the log of the sums of exponents without arithmetic underflows. This allows very small numbers to be summed in log space.

Usage

lse(a, b)

Value

The log of the sum of the exponents of a and b.

Arguments

a

A numeric log value.

b

Another numeric log value.

Examples

Run this code

A <- 1E-40
B <- 3E-41

log_AB <- lse( log(A), log(B) )

# exp( log_AB ) == A + B


Run the code above in your browser using DataLab