log_normalize: Normalize in log space

Description Usage Arguments Value Author(s) Examples

View source: R/log_normalize.R

Description

Binding to a C implementation of addition and normalization in log space.

Usage

1
log_normalize(vals, maxi = max(vals), ID = which.max(vals)[1])

Arguments

vals

Log-values to be normalize

maxi

The maximum value of vals

ID

One entry of vals which has the highest value.

Value

A list with three slots. First one is a numerical vector with values normalized so that they sum to 1. The second is the same normalized vector in log space. The last one is the log of the normalization constant. See example.

Author(s)

Edouard Pauwels

Examples

1
2
3
4
5
6
7
8
9
log_x <- rnorm(10)

temp <- log_normalize(log_x)

exp(temp[[2]]) - temp[[1]]

sum(exp(temp[[2]]))

log_x - temp[[3]] - temp[[2]]

pauwels2014 documentation built on May 1, 2019, 6:29 p.m.