Learn R Programming

SSLfmm (version 0.1.0)

logsumexp: Numerically Stable Log-Sum-Exp

Description

Computes \(\log(\sum_i \exp(x_i))\) in a numerically stable way by subtracting the maximum value before exponentiation.

Usage

logsumexp(x)

Value

A single numeric value: the log-sum-exp of x.

Arguments

x

A numeric vector.

Examples

Run this code
logsumexp(c(1000, 1001, 1002))

Run the code above in your browser using DataLab