Skip to content
GATEiit

GATE DA · Machine Learning

Linear discriminant analysis

Linear discriminant analysis: a generative classifier that assumes Gaussian classes with a shared covariance, giving linear decision boundaries, and Fisher's view of it as the projection that best separates class means relative to within-class spread.

Before you start

Concept notes

1. The generative model

LDA is a generative classifier. For classes k=1,…,K it assumes

  • prior probabilities πk=P(y=k), and
  • class-conditional densities that are multivariate normal with a common covariance: x∣y=k∼N(μk,Σ).

By Bayes' theorem it predicts the class with the largest πk p(x∣k). Taking logs and dropping terms that are the same for every class (the x⊤Σ−1x term cancels because Σ is shared) gives the linear discriminant function δk(x)=x⊤Σ−1μk−12μk⊤Σ−1μk+ln⁡πk, and the rule y^=arg⁡max⁡kδk(x).

δk is linear in x, so every boundary δj(x)=δk(x) is a hyperplane.

Estimating the parameters from training data:

  • π^k=nk/n,
  • μ^k = mean of class-k points,
  • Σ^ = pooled within-class covariance, 1n−K∑k∑i∈k(xi−μ^k)(xi−μ^k)⊤.

Special case Σ=σ2I and equal priors: δk ranks classes by distance to μk, so LDA becomes the nearest-mean classifier.

class 1, mean m₁ class 2, mean m₂ boundary (linear) w ∝ S_W⁻¹(m₂ − m₁) direction Same covariance shape for both classes
Two Gaussian classes with the same covariance: LDA's boundary is a straight line

2. Two classes in one dimension

With one feature, means μ1<μ2, common variance σ2 and priors π1,π2, LDA assigns x to class 2 when δ2(x)>δ1(x): xμ2−μ1σ2>μ22−μ122σ2+ln⁡π1π2. So the threshold is x∗=μ1+μ22+σ2μ2−μ1ln⁡π1π2.

  • Equal priors: x∗ is the midpoint of the means.
  • A larger prior for class 1 pushes x∗ towards class 2's mean, enlarging class 1's region.
  • A larger variance makes the prior shift bigger; well-separated means make it smaller.

In d dimensions with two classes, the boundary is w⊤x=c with w=Σ−1(μ2−μ1),c=12w⊤(μ1+μ2)+ln⁡π1π2.

Always check which class has the larger mean before using the formula; the sign of the log term follows from that.

3. Fisher's linear discriminant

Fisher asked a different question: which direction w should we project onto so that the two classes are as separated as possible?

Project x↦w⊤x. Let m1,m2 be the class means. Define

  • between-class scatter SB=(m2−m1)(m2−m1)⊤,
  • within-class scatter SW=∑k∑i∈k(xi−mk)(xi−mk)⊤.

Fisher's criterion is the ratio of between-class to within-class spread of the projected data: J(w)=w⊤SBww⊤SWw=(w⊤(m2−m1))2w⊤SWw. Maximising it gives w∗∝SW−1(m2−m1). Only the direction matters (J does not change when w is scaled), so you may rescale the answer.

This is the same direction as the two-class Gaussian LDA boundary normal, since SW is proportional to the pooled covariance. If SW is a multiple of I, w is simply along m2−m1.

Multiclass: the best directions are the leading eigenvectors of SW−1SB. Since SB has rank at most K−1, LDA yields at most K−1 useful directions; this is its use as supervised dimensionality reduction.

4. LDA, QDA, logistic regression and PCA

LDA QDA Logistic regression PCA
Uses labels yes yes yes no
Model Gaussian, shared Σ Gaussian, own Σk P(y∣x) directly none (variance)
Boundary linear quadratic linear n/a
Parameters (covariance) d(d+1)2 Kd(d+1)2 — —
  • QDA (quadratic discriminant analysis) lets each class have its own covariance. The x⊤Σk−1x term no longer cancels, so boundaries are quadratic. QDA is more flexible but has many more parameters, so it needs more data.
  • LDA vs logistic regression: both give linear boundaries. When the Gaussian shared-covariance assumption holds, LDA uses data more efficiently; when it fails (e.g. heavy outliers, non-Gaussian features), logistic regression is more robust.
  • LDA vs PCA: PCA finds directions of maximum total variance and ignores labels, so its first component may mix the classes. LDA finds directions that separate the classes.

When to use LDA: few training points per class, roughly Gaussian features, a linear boundary is enough, or you need a low-dimensional projection that keeps classes apart.

Formulas to remember

Linear discriminant function
δk(x)=x⊤Σ−1μk−12μk⊤Σ−1μk+ln⁡πk
1-D two-class thresholdAssign class 2 when x>x∗, with μ2>μ1
x∗=μ1+μ22+σ2μ2−μ1ln⁡π1π2
Fisher criterion
J(w)=w⊤SBww⊤SWw
Fisher direction
w∗∝SW−1(m2−m1)
Within-class scatter
SW=∑k∑i∈Ck(xi−mk)(xi−mk)⊤
Number of LDA directions
≤min⁡(K−1, d)

Common mistakes

  • Dropping the ln⁡πk term when the priors are unequal; it shifts the boundary.
  • Getting the sign of the prior shift wrong in 1-D; the class with the larger prior gets the larger region.
  • Using SB−1 or SW(m2−m1) instead of SW−1(m2−m1) for Fisher's direction.
  • Confusing LDA with PCA: LDA uses labels and separates classes; PCA ignores labels.
  • Claiming LDA can give K or more directions; it gives at most K−1.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Fisher direction from data

numerical

Class 1: (1, 1), (2, 3), (3, 2). Class 2: (5, 6), (6, 5), (7, 7). Find Fisher's discriminant direction.

  1. Step 1: Find the class means.

    Try it on paper first.

Example 2: Effect of unequal priors in 1-D

numerical

Class 1: μ1=2; class 2: μ2=6; common variance σ2=4. Find the LDA threshold for (a) equal priors, (b) π1=0.8, π2=0.2. Classify x=5 in each case.

  1. Step 1: Equal priors.

    Try it on paper first.

Example 3: Discriminant scores with identity covariance

numerical

Σ=I, μ1=(1,1), μ2=(3,3), equal priors. Classify x=(2,1).

  1. Step 1: Write $\delta_k$ for $\Sigma = I$.

    Try it on paper first.

Example 4: Why only K − 1 directions?

conceptual

A dataset has 10 features and 3 classes. How many useful LDA projection directions exist, and why?

  1. Step 1: Look at the rank of $S_B$.

    Try it on paper first.

Previous year questions

2 official GATE DA questions on this topic, newest first.

Practise these 2 PYQs →

Topic test

10 questions: up to 2 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE DA syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.