inv_smax: The inverse softmax function.

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/utils.r

Description

The inverse softmax function: take a logarithm and center.

Usage

1
inv_smax(mu, g = NULL)

Arguments

mu

a vector of the probablities. Must be the same length as g if g is given. If mu and eta are both given, we ignore eta and use mu.

g

a vector giving the group indices. If NULL, then we assume only one group is in consideration.

Details

This is the inverse of the softmax function. Given vector μ for a single group, finds vector η such that

η_i = \log{μ_i} + c,

where c is chosen such that the η sum to zero:

c = \frac{-1}{n} ∑_i \log{μ_i}.

Value

the centered log probabilities.

Note

This function can deal with overflow in a semi-coherent way.

Author(s)

Steven E. Pav shabbychef@gmail.com

See Also

smax

Examples

1
2
3
4
5
# we can deal with large values:
set.seed(2345)
eta <- rnorm(12,sd=1000)
mu <- smax(eta)
eta0 <- inv_smax(mu)

Example output



ohenery documentation built on Oct. 30, 2019, 9:53 a.m.