log_sum_exp: log_sum_exp

View source: R/log_sum_exp.R

log_sum_expR Documentation

log_sum_exp

Description

Computes the log sum exp of a vector. Given input array = [x_1, ..., x_n], returns x_* + log(exp(x_1 - x_*) + ... + exp(x_n - x_*)), where x_* = max(x_1, ... x_n). Ignores entries with NA value.

Usage

log_sum_exp(x)

Arguments

x

Input vector.

Value

The log-sum-exp of the entries of the input vector.

Examples

library(perms)
x = c(1,2,3,-1,-1,1)
log_sum_exp(x)

perms documentation built on Sept. 11, 2024, 9:01 p.m.

Related to log_sum_exp in perms...