Learn R Programming

ohenery (version 0.1.3)

inv_smax: The inverse softmax function.

Description

The inverse softmax function: take a logarithm and center.

Usage

inv_smax(mu, g = NULL)

Value

the centered log probabilities.

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.

Author

Steven E. Pav shabbychef@gmail.com

Details

This is the inverse of the softmax function. Given vector \(\mu\) for a single group, finds vector \(\eta\) such that $$\eta_i = \log{\mu_i} + c,$$ where \(c\) is chosen such that the \(\eta\) sum to zero: $$c = \frac{-1}{n} \sum_i \log{\mu_i}.$$

See Also

smax

Examples

Run this code
# we can deal with large values:
set.seed(2345)
eta <- rnorm(12,sd=1000)
mu <- smax(eta)
eta0 <- inv_smax(mu)

Run the code above in your browser using DataLab