smax | R Documentation |
The softmax function: exponentiate a vector and then normalize.
smax(eta, g = NULL)
eta |
numeric array of the odds. The odds are de-meaned within each group. |
g |
a vector giving the group indices. If |
Given vector \eta
for a single group, essentially
computes vector \mu
defined by
\mu_i = \frac{\exp{\eta_i}}{\sum_j \exp{\eta_j}}.
Note that this computation should be invariant with respect
to level shifts of the \eta
, and thus we de-mean
the odds first.
the exponentiated data normalized. For the row-wise version, each row is soft maxed.
This function can deal with overflow in a semi-coherent way.
Steven E. Pav shabbychef@gmail.com
normalize
, inv_smax
.
# we can deal with large values:
set.seed(2345)
eta <- rnorm(12,sd=1000)
smax(eta)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.