softmax: softmax

View source: R/softmax.R

softmaxR Documentation

softmax

Description

Calculates the softmax function for mapping a set of real values to a probability distribution. The maxima/um receives quite a bit of weight via softmax: Given the values [4, 4, 4, 5], softmax returns a probability of .475 for the final element and 0.175 for each of the first three.

Usage

softmax(x, digits = NULL)

Arguments

x

A double or integer vector.

digits

The number of digits to round the output probabilities to.

Value

A length-one vector.

Examples

x <- c(3.5, 4.0, 6.5)
softmax(x)
softmax(x, digits = 4)

x <- c(NA, 3.5, 4.0, 6.5)
softmax(x, 4)


jacob-gg/manager documentation built on July 2, 2024, 2:09 a.m.