reverseSoftmax: Reverse of the Softmax Function

Description Usage Arguments Value Examples

View source: R/utility_functions.R

Description

A function that, given a vector of probabilities that sum to one, will determine the closest values that could be passed to the softmax function to produce those probabilities using the optim function.

Usage

1
reverseSoftmax(y, init = NULL, restrict = NULL)

Arguments

y

a vector of probabilities (positive, sum to 1).

init

the starting values for the optim function. If empty, generates random values from a normal distribution.

restrict

a logical vector indicating whether certain values of x should be fixed to 0.

Value

The output from the optim function.

Examples

1
2
3
4
5
6
set.seed(984)
input = rnorm(5)
sm = softmax( input )
output = reverseSoftmax( sm )
round(sm,3)
round(output$par,3)

rettopnivek/utilityf documentation built on March 1, 2021, 7:05 p.m.