Tutorials › Multivariate Statistics (Graduate) › The Multiclass Fisher Discriminant Eigenproblem

Discriminant Analysis Theory · Tutorial 598 of 975

The Multiclass Fisher Discriminant Eigenproblem

Learn how class scatter matrices lead to generalized eigenvectors and how to calculate and interpret the resulting discriminant directions.

Intermediate 10 min read

What You'll Learn

  • Define between-class and within-class scatter for labelled multivariate observations
  • Derive the generalized eigen-equation from Fisher’s single-direction criterion
  • Explain why within-scatter normalization is part of the multiclass problem
  • Prove the trace-maximization result for one or more directions
  • Compute and normalize discriminant directions from explicit class data
  • Recognize why ordinary eigenvectors of between-class scatter can be misleading

From Separating One Direction to Several

For two classes, a direction can be assessed by comparing how far apart the projected class means are with how much projected variation occurs within the classes. With several classes, the same idea applies, but the mean differences point in multiple directions. The multiclass Fisher discriminant problem gathers those differences into a matrix and asks which directions provide the greatest between-class separation relative to within-class variation.

The result is a generalized eigenvalue problem, not ordinarily an eigenproblem for the between-class scatter matrix alone. The within-class scatter matrix supplies the metric in which directions are compared and normalized.

Definition: Suppose \(n\) labelled observations \(x_i\in\mathbb{R}^p\) belong to \(K\) classes, with \(n_k\ge 1\) observations in class \(k\). Write \(\bar{x}_k\) for the sample mean in class \(k\), and \(\bar{x}=\sum_{k=1}^K n_k\bar{x}_k/n\) for the overall mean. The between-class and within-class scatter matrices are $$ B=\sum_{k=1}^K n_k(\bar{x}_k-\bar{x})(\bar{x}_k-\bar{x})^T,\qquad W=\sum_{k=1}^K\sum_{i:\,x_i\text{ in class }k}(x_i-\bar{x}_k)(x_i-\bar{x}_k)^T. $$ Both are \(p\times p\) symmetric positive semidefinite matrices. Here, “scatter” means a sum of outer products, without division by a degrees-of-freedom factor.

If \(a\in\mathbb{R}^p\) is a nonzero direction, projecting an observation onto it gives the scalar \(a^Tx_i\). The weighted sum of squared differences between projected class means is \(a^TBa\), while the sum of within-class squared deviations after projection is \(a^TWa\). Thus, when \(a^TWa>0\), Fisher’s one-direction criterion is $$ J(a)=\frac{a^TBa}{a^TWa}. $$ Multiplying \(a\) by any nonzero constant does not change \(J(a)\), so a normalization is needed to select a particular representative of a direction.

Worked Example: Three Classes on a Line

Consider three classes with observations \(C_1=\{-2,0\}\), \(C_2=\{0,2\}\), and \(C_3=\{2,4\}\). Each class has two observations, and their means are \(\bar{x}_1=-1\), \(\bar{x}_2=1\), and \(\bar{x}_3=3\). The overall mean is \(\bar{x}=1\).

Within each class, the two deviations from its mean are \(-1\) and \(1\), so each class contributes \(1^2+(-1)^2=2\) to \(W\). Therefore \(W=2+2+2=6\). The between-class scatter is $$ B=2(-1-1)^2+2(1-1)^2+2(3-1)^2=8+0+8=16. $$ For a scalar direction \(a\ne0\), \(J(a)=16a^2/(6a^2)=8/3\). The generalized eigen-equation is \(16a=\lambda 6a\), giving \(\lambda=8/3\). To impose \(a^TWa=1\), choose \(a=1/\sqrt{6}\); its negative represents the same direction.

The Generalized Eigen-Equation

The single-direction problem is to maximize \(J(a)\) over nonzero \(a\) for which \(a^TWa>0\). If \(W\) is positive definite, then every nonzero direction has positive within-class scatter. The quotient is unchanged by rescaling \(a\), so we may impose \(a^TWa=1\) and maximize \(a^TBa\). A Lagrange multiplier gives $$ Ba=\lambda Wa. $$ Indeed, the gradient of \(a^TBa-\lambda(a^TWa-1)\) is \(2Ba-2\lambda Wa\), since both matrices are symmetric. Multiplying the equation by \(a^T\) shows that \(\lambda=a^TBa\) under the normalization \(a^TWa=1\). Equivalently, for any nonzero solution, its generalized eigenvalue is the quotient \(J(a)\).

Result: If \(W\) is positive definite, the maximum of \(J(a)\) is the largest generalized eigenvalue in \(Ba=\lambda Wa\). A maximizing direction is its corresponding eigenvector. If that eigenvalue is repeated, every nonzero vector in its generalized eigenspace is maximizing.

This result can be derived by converting the generalized problem into an ordinary symmetric eigenproblem. A positive definite \(W\) has a symmetric positive definite square root \(W^{1/2}\) and inverse \(W^{-1/2}\). Set \(u=W^{1/2}a\), and define \(C=W^{-1/2}BW^{-1/2}\). Then $$ J(a)=\frac{u^TCu}{u^Tu}. $$ The matrix \(C\) is symmetric, so the spectral theorem gives an orthonormal eigenbasis and real eigenvalues. Expressing \(u\) in that basis shows that its quotient is a weighted average of the eigenvalues, with nonnegative weights summing to one. It cannot exceed the largest eigenvalue, and equality is attained by a corresponding eigenvector \(u\). Transforming back gives \(a=W^{-1/2}u\), which satisfies \(Ba=\lambda Wa\). This also explains why the generalized eigenvalues are real. Since \(B\) is positive semidefinite, they are nonnegative.

Worked Example: Computing Two Directions From Class Data

Take three classes in two dimensions: \(C_1=\{(0,0),(2,0)\}\), \(C_2=\{(4,0),(4,2)\}\), and \(C_3=\{(0,4),(2,4)\}\). Their means are \((1,0)\), \((4,1)\), and \((1,4)\), and the overall mean is \((2,5/3)\).

For \(C_1\), the two residuals are \((-1,0)\) and \((1,0)\), contributing \(\begin{pmatrix}2&0\\0&0\end{pmatrix}\) to \(W\). For \(C_2\), the residuals are \((0,-1)\) and \((0,1)\), contributing \(\begin{pmatrix}0&0\\0&2\end{pmatrix}\). For \(C_3\), they are again \((-1,0)\) and \((1,0)\). Thus $$ W=\begin{pmatrix}4&0\\0&2\end{pmatrix}. $$ The deviations of the class means from the overall mean are \((-1,-5/3)\), \((2,-2/3)\), and \((-1,7/3)\). Each class has size two, so summing twice their outer products gives $$ B=\begin{pmatrix}12&-4\\-4&52/3\end{pmatrix}. $$ Now solve \(Ba=\lambda Wa\). Its characteristic equation is $$ \det(B-\lambda W) =(12-4\lambda)(52/3-2\lambda)-16=0, $$ which reduces to \(3\lambda^2-35\lambda+72=0\). The roots are \(\lambda_1=9\) and \(\lambda_2=8/3\). For \(\lambda_1=9\), the first row of \(B-\lambda W\) gives \(-24a_1-4a_2=0\), so one eigenvector is \((1,-6)^T\). For \(\lambda_2=8/3\), it gives \((4/3)a_1-4a_2=0\), so one eigenvector is \((3,1)^T\).

The required \(W\)-normalizations are \((1,-6)W(1,-6)^T=76\) and \((3,1)W(3,1)^T=38\). Thus normalized directions are $$ a_1=\frac{1}{\sqrt{76}}\begin{pmatrix}1\\-6\end{pmatrix}, \qquad a_2=\frac{1}{\sqrt{38}}\begin{pmatrix}3\\1\end{pmatrix}. $$ They are \(W\)-orthogonal: \((1,-6)W(3,1)^T=12-12=0\). Their generalized eigenvalues give the Fisher criteria for the two directions.

Choosing Several Discriminant Directions

For an \(r\)-dimensional discriminant representation, put the direction vectors in a \(p\times r\) matrix \(A\). The projected between-class scatter is \(A^TBA\), and the projected within-class scatter is \(A^TWA\). A standard joint choice fixes the within-class scatter to the identity and maximizes the total between-class scatter: $$ \text{maximize }\operatorname{tr}(A^TBA) \quad\text{subject to }A^TWA=I_r. $$ Here \(I_r\) is the \(r\times r\) identity matrix and \(\operatorname{tr}\) is the sum of diagonal entries. This optimization is defined for \(1\le r\le p\): when \(W\) is positive definite, \(r\) \(W\)-orthonormal directions can be selected in \(\mathbb{R}^p\), but more than \(p\) cannot.

Theorem: Let \(B\) be symmetric positive semidefinite and \(W\) symmetric positive definite, both \(p\times p\). For \(1\le r\le p\), the maximum of \(\operatorname{tr}(A^TBA)\) subject to \(A^TWA=I_r\) is the sum of the \(r\) largest generalized eigenvalues of \(Ba=\lambda Wa\). A maximizing \(A\) has as its columns \(W\)-normalized generalized eigenvectors for those eigenvalues, chosen to be mutually \(W\)-orthogonal. If there are ties at the selection boundary, any suitable orthonormal choice within the tied eigenspace is valid.

To prove the theorem, form \(C=W^{-1/2}BW^{-1/2}\) and set \(Q=W^{1/2}A\). The constraint becomes \(Q^TQ=I_r\), and the objective becomes \(\operatorname{tr}(Q^TCQ)\). Let the eigenvalues of \(C\) be ordered \(\lambda_1\ge\cdots\ge\lambda_p\), with corresponding orthonormal eigenvectors in the columns of \(U\). Write \(Z=U^TQ\). Then \(Z^TZ=I_r\), and $$ \operatorname{tr}(Q^TCQ)=\sum_{i=1}^p\lambda_i d_i,\qquad d_i=\sum_{j=1}^r z_{ij}^2. $$ Each \(d_i\) lies between zero and one: it is the squared length of the projection of a unit coordinate vector onto the \(r\)-dimensional column space of \(Z\). Also \(\sum_i d_i=\operatorname{tr}(Z^TZ)=r\). Consequently, $$ \sum_{i=1}^r\lambda_i-\sum_{i=1}^p\lambda_i d_i =\sum_{i=1}^r\lambda_i(1-d_i)-\sum_{i=r+1}^p\lambda_i d_i\ge 0. $$ For the inequality, the total weights on the two sums are equal because \(\sum_{i=1}^r(1-d_i)=\sum_{i=r+1}^p d_i\). Every eigenvalue in the first sum is at least \(\lambda_r\), and every eigenvalue in the second is at most \(\lambda_r\). The bound is attained by taking the columns of \(Q\) to be eigenvectors for the \(r\) largest eigenvalues. Mapping back with \(A=W^{-1/2}Q\) gives \(A^TWA=I_r\), and its columns solve the generalized eigen-equation. This proves the stated maximum and characterization. \(\square\)

Worked Example: Selecting One Direction From Three Classes

Consider the six two-dimensional observations in three classes: \(C_1=\{(-2,-1),(0,-1)\}\), \(C_2=\{(1,-2),(1,0)\}\), and \(C_3=\{(-1,2),(1,2)\}\). Their means are \((-1,-1)\), \((1,-1)\), and \((0,2)\), whose average is \((0,0)\).

The within-class residuals in \(C_1\) and \(C_3\) are \((-1,0)\) and \((1,0)\); each contributes \(\begin{pmatrix}2&0\\0&0\end{pmatrix}\). The residuals in \(C_2\) are \((0,-1)\) and \((0,1)\), contributing \(\begin{pmatrix}0&0\\0&2\end{pmatrix}\). Hence \(W=\begin{pmatrix}4&0\\0&2\end{pmatrix}\). Using the three class means and their common class size of two gives $$ B=2\left[ \begin{pmatrix}1&1\\1&1\end{pmatrix} +\begin{pmatrix}1&-1\\-1&1\end{pmatrix} +\begin{pmatrix}0&0\\0&4\end{pmatrix} \right] =\begin{pmatrix}4&0\\0&12\end{pmatrix}. $$ The generalized eigenvalues are \(4/4=1\) in the first coordinate and \(12/2=6\) in the second. The largest is \(6\), so the leading direction is \((0,1)^T\); its \(W\)-normalized version is \((0,1/\sqrt{2})^T\). For comparison, the normalized first-coordinate direction is \((1/2,0)^T\) and has criterion \(1\). The second coordinate is preferred because its between-class scatter is larger relative to its within-class scatter.

Common Pitfall and Practical Interpretation

A common mistake is to take the ordinary eigenvectors of \(B\) and assume they solve the Fisher problem. Those eigenvectors maximize between-class scatter under Euclidean normalization, not under within-class normalization. Fisher’s criterion instead compares \(a^TBa\) with \(a^TWa\); the correct equation is \(Ba=\lambda Wa\). The distinction matters when within-class variability differs across features or combines features through off-diagonal entries. The examples also show why the normalization \(A^TWA=I_r\) is substantive: it makes the chosen directions orthonormal in the within-class scatter metric, rather than merely in ordinary Euclidean distance.

The positive-definiteness assumption on \(W\) ensures that every nonzero direction has positive within-class scatter and that the whitening transformation used in the proofs exists. If \(W\) is singular, these arguments do not apply directly; the data may have directions with zero within-class scatter, and the problem needs an explicitly chosen restriction or regularization before using an ordinary generalized eigenproblem. Likewise, the dimension \(r\) in the trace theorem must satisfy \(1\le r\le p\); for \(r>p\), the constraint has no feasible \(p\times r\) matrix.

These directions summarize class-mean separation relative to within-class scatter. They are useful for constructing a lower-dimensional representation of labelled data, but the eigenvalues are separation criteria, not posterior probabilities or classification error rates. Classification still requires a decision rule and, where appropriate, class priors and misclassification costs.

Check Your Understanding

Use the definitions and results above to check the role of the scatter matrices and the eigenproblem.

  1. For a direction \(a\), what do \(a^TBa\) and \(a^TWa\) measure after projection?
  2. Why does maximizing \(J(a)\) lead to \(Ba=\lambda Wa\) rather than \(Ba=\lambda a\)?
  3. In the two-dimensional worked example, verify that the first normalized direction has \(a_1^TWa_1=1\).
  4. What is the maximum trace objective for \(r=1\) in the trace theorem, and what is it for \(r=p\)?
  5. Why is the stated trace maximization not feasible when \(r>p\)?
Clinical Biostats