Computes the softmax transformation of a numeric vector, returning a probability vector that sums to 1.
Details
The softmax function is defined as: $$p_i = \frac{\exp(x_i)}{\sum_j \exp(x_j)}$$
This implementation subtracts the maximum value before exponentiating to ensure numerical stability for extreme inputs.
Special cases:
If
xcontainsInfvalues, the probability mass is split uniformly across allInfentries.Empty vector throws an error.