From Baseline Logits to Category Probabilities
A baseline-category logit model describes a response that can fall into one of \(K\) categories. For a fixed covariate profile, the model uses a predictor for each nonbaseline category relative to a designated baseline. Those predictors are log ratios, not probabilities: they can be negative, positive, or any finite real number. The softmax map converts them into a full set of category probabilities.
The conversion has to satisfy two requirements. Each probability must be positive, and the probabilities across all categories must add to one. The baseline category is included in the normalization even though it has no separately estimated predictor: its relative weight is one. This tutorial derives that normalization, checks its properties, and works through calculations in both directions.
In a regression model, each nonbaseline predictor may depend on covariates, for example through a linear expression \(\eta_j(x)\). The probability calculation below is carried out at one fixed profile \(x\), so we write \(\eta_j\) rather than repeatedly including \(x\). The baseline convention is equivalent to setting \(\eta_K=0\); this is a convenient way to include the baseline in the same normalization as the other categories.
Deriving the Softmax Formula
Start from the defining log-ratio equations for the nonbaseline categories. Exponentiating each equation gives \(p_j/p_K=\exp(\eta_j)\), or \(p_j=p_K\exp(\eta_j)\). Thus every nonbaseline probability is its baseline probability multiplied by a relative weight. The requirement that all category probabilities sum to one determines the common scale \(p_K\).
For each \(j<K\), \(p_j=p_K\exp(\eta_j)\).
Substitute those expressions into \(p_K+\sum_{j=1}^{K-1}p_j=1\), giving \(p_K\left(1+\sum_{r=1}^{K-1}\exp(\eta_r)\right)=1\).
Since the expression in parentheses is positive, \(p_K=1/\left(1+\sum_{r=1}^{K-1}\exp(\eta_r)\right)\).
Insert this value of \(p_K\) into \(p_j=p_K\exp(\eta_j)\).
Equivalently, define \(\eta_K=0\) and include all \(K\) categories in the denominator:
The two forms are identical because \(\exp(\eta_K)=\exp(0)=1\). The baseline has a numerator too; it is simply one. The denominator is the sum of all category weights, not just the weights for categories with estimated predictors.
Worked Example: Two Predictors With Exact Exponentials
There are three categories, with category 3 as the baseline. Suppose \(\eta_1=\log 2\) and \(\eta_2=\log 3\). Find all three probabilities.
First compute the weights: \(\exp(\eta_1)=2\), \(\exp(\eta_2)=3\), and the baseline weight is \(1\). The denominator is therefore \(1+2+3=6\). The probabilities are
They sum to \(1/3+1/2+1/6=2/6+3/6+1/6=1\), and each is positive. As a check against the original predictors, \(p_1/p_3=(1/3)/(1/6)=2\) and \(p_2/p_3=(1/2)/(1/6)=3\). Taking logarithms gives \(\log 2\) and \(\log 3\), as specified.
Why the Formula Gives Valid Probabilities
The softmax formula is defined for finite real predictors. Its denominator contains positive terms, including the baseline term \(1\), so it cannot be zero. The next result checks both the range of each probability and the sum constraint. The condition \(K\ge2\) matters: with one category there are no nonbaseline predictors, and its sole probability is one.
Proof. Set \(D=1+\sum_{r=1}^{K-1}\exp(\eta_r)\). Each exponential is finite and strictly positive, and \(D\) includes the positive term \(1\), so \(0<D<\infty\). For \(j<K\), \(p_j=\exp(\eta_j)/D>0\); also \(p_K=1/D>0\). For a nonbaseline category, \(D\) contains its numerator \(\exp(\eta_j)\) and the additional positive baseline term \(1\), so \(D>\exp(\eta_j)\) and \(p_j<1\). For the baseline, \(K\ge2\) ensures that the sum defining \(D\) includes at least one positive exponential term, so \(D>1\) and \(p_K<1\). Finally,
Thus the softmax outputs are strictly positive probabilities summing to one. \(\square\)
A useful way to interpret the calculation is that the unnormalized weights are \(\exp(\eta_1),\ldots,\exp(\eta_{K-1}),1\). Dividing every weight by their total produces probabilities without changing the relative weight of any pair of categories. In particular, the baseline ratio remains \(p_j/p_K=\exp(\eta_j)\).
Worked Example: Predictors That Are Not Logarithms of Integers
For three categories with category 3 as baseline, suppose \(\eta_1=\log 4\) and \(\eta_2=\log(1/2)\). Calculate the probabilities and verify that they sum to one.
The three weights are \(4\), \(1/2\), and \(1\). Their total is \(4+1/2+1=11/2\). Dividing each weight by \(11/2\) gives
The sum is \(8/11+1/11+2/11=11/11=1\). The probabilities recover the specified relative weights: \(p_1/p_3=(8/11)/(2/11)=4\), while \(p_2/p_3=(1/11)/(2/11)=1/2\). A negative predictor such as \(\log(1/2)\) therefore gives a weight below one, but it still gives a positive probability.
The Inverse Map: Recovering Predictors
The relationship also works in reverse, provided every category has positive probability. This positivity condition is necessary for the logarithms of the probability ratios to be finite. The result says that the softmax map gives a one-to-one correspondence between finite baseline predictors and probability vectors in the interior of the \(K\)-category probability simplex.
Proof. The forward direction follows from the preceding theorem. For the converse, define \(\eta_j=\log(p_j/p_K)\). These are finite real numbers because \(p_j>0\) and \(p_K>0\). Exponentiating gives \(\exp(\eta_j)=p_j/p_K\), so the softmax denominator is
The softmax probability for category \(j<K\) is therefore \((p_j/p_K)/(1/p_K)=p_j\), and the baseline probability is \(1/(1/p_K)=p_K\). This proves existence. For uniqueness, if any finite predictors produce the given probabilities, their baseline ratios must satisfy \(\exp(\eta_j)=p_j/p_K\). Taking the logarithm forces \(\eta_j=\log(p_j/p_K)\) for every \(j<K\). Hence no other finite predictor vector produces the same probabilities. \(\square\)
Worked Example: Recovering Predictors From Probabilities
Suppose the probabilities for three categories are \(p_1=0.2\), \(p_2=0.5\), and \(p_3=0.3\), with category 3 as baseline. Find the baseline-category predictors, then verify that the softmax map returns the original probabilities.
The probabilities are all positive and sum to \(0.2+0.5+0.3=1\), so the inverse formula applies. The predictors are
Their exponentiated weights are \(2/3\) and \(5/3\), with baseline weight \(1\). The denominator is \(1+2/3+5/3=10/3\). Consequently,
The reconstructed values match the starting probabilities, as the inverse result guarantees.
Reading a Multicategory Calculation Carefully
For more than three categories, the same steps apply without alteration: exponentiate each nonbaseline predictor, append a baseline weight of one, sum all the weights, and divide each weight by that sum. Keeping the baseline weight visible is a practical safeguard against omitting a category from the denominator.
Worked Example: Four Categories With a Baseline Weight
Take category 4 as baseline and suppose \(\eta_1=\log 2\), \(\eta_2=\log 5\), and \(\eta_3=\log(1/2)\). Find the four probabilities.
The weights for categories 1, 2, and 3 are \(2\), \(5\), and \(1/2\); category 4 has weight \(1\). The total weight is \(2+5+1/2+1=17/2\). Thus
Their sum is \((4+10+1+2)/17=17/17=1\). The smallest weight is still positive, so category 3 has positive probability even though its predictor is negative.
Common Mistakes and Why the Map Matters
- Omitting the baseline weight. A tempting but incorrect denominator is \(\sum_{r=1}^{K-1}\exp(\eta_r)\). That expression leaves out the baseline category and generally makes the probabilities sum to more than one when the baseline probability is added. Include its weight \(1=\exp(0)\).
- Treating predictors as probabilities. A predictor can be negative or greater than one, while a probability must lie between zero and one. Exponentiating and normalizing—not interpreting \(\eta_j\) directly—produces the probability.
- Claiming finite predictors can produce a zero probability. For every finite real \(\eta_j\), \(\exp(\eta_j)>0\), so the softmax probability is strictly positive. A probability vector containing a zero cannot be represented by finite baseline predictors through the inverse logarithm formula.
- Forgetting the number of categories. The strict upper bound \(p_j<1\) uses \(K\ge2\). With just one category, the only probability is \(1\), and there are no nonbaseline predictors.
The softmax map matters because it turns unconstrained finite real predictors into a valid probability vector at each covariate profile. It also makes clear what information the predictors encode: each one specifies a log ratio to the baseline, while the normalization determines all category probabilities together.
Check Your Understanding
Use the baseline weight of one whenever you calculate a softmax denominator.
- With three categories and category 3 as baseline, calculate the probabilities for \(\eta_1=0\) and \(\eta_2=\log 2\).
- Why does the proof that every softmax probability is less than one require \(K\ge2\)?
- For \(K=4\), write the softmax denominator when category 4 is the baseline.
- Given strictly positive probabilities \(p_1,\ldots,p_K\) summing to one, what is the unique baseline predictor for category \(j<K\)?
- Can a finite baseline predictor vector produce a probability vector with \(p_1=0\)? Explain using the formula or the inverse map.