Skip to content
GATEiit

GATE EC, AE, CE, EE, IN + 10 more · Probability and Statistics

Correlation, Linear Regression and Least Squares

Covariance, Pearson correlation r, correlation vs independence, both OLS regression lines, normal equations, R^2 coefficient of determination, overdetermined Ax ≈ b, and nonlinear curve linearization.

Before you start

  • Mean and standard deviation →

    Correlation and regression coefficients are built from means, variances and the covariance.

  • Joint distributions and expectation →

    For random variables, covariance is E[XY]−E[X]E[Y], and independence is a joint-distribution idea.

  • Equation of a straight line

    Regression lines are straight lines; you must read slopes and intercepts from equations like ax+by=c.

  • Systems of linear equations →

    Minimizing squared residuals reduces directly to solving a 2 × 2 normal linear system.

Concept notes

1. Covariance and the correlation coefficient

For n pairs (xi,yi) with means xˉ,yˉ, the covariance is

cov⁡(x,y)=1n∑(xi−xˉ)(yi−yˉ)=1n∑xiyi−xˉ yˉ

Its sign shows the direction of the linear trend, but its size depends on units. Dividing by the standard deviations gives Karl Pearson's correlation coefficient

r=cov⁡(x,y)σxσy=∑dxdy∑dx2∑dy2,dx=xi−xˉ,  dy=yi−yˉ

Key properties

  • −1≤r≤1. r=±1 only when all points lie on one straight line.
  • r has no units. It is unchanged by a change of origin and scale: if u=(x−a)/h and v=(y−b)/k, then ruv=rxy when h,k have the same sign, and ruv=−rxy when they have opposite signs.
  • r measures only linear association. r=0 means uncorrelated, not independent. Points on a parabola y=x2, with x symmetric about 0, give r=0.
  • r=0.8 is not "twice as strong" as r=0.4; compare r2 instead (see regression).

For the 1/n versus 1/(n-1) question: use the same divisor in covariance and variances and it cancels in r.

2. Correlation of random variables

For random variables X and Y:

Cov⁡(X,Y)=E[(X−μX)(Y−μY)]=E[XY]−E[X] E[Y],ρXY=Cov⁡(X,Y)σXσY

Results used in GATE

  • Var⁡(aX+bY)=a2σX2+b2σY2+2ab Cov⁡(X,Y).
  • Cov⁡(aX+b,cY+d)=ac Cov⁡(X,Y); constants added do not matter.
  • Cov⁡(X,X)=σX2, and covariance is linear in each argument.
  • Independent ⇒ uncorrelated (E[XY]=E[X]E[Y]). The converse is false in general. Example: X uniform on {−1,0,1} and Y=X2 are uncorrelated but fully dependent.
  • For jointly Gaussian X,Y, uncorrelated does imply independent. This is why white Gaussian noise samples that are uncorrelated are also independent.

A common question: X,Y independent, find the correlation of U=X+Y and V=X−Y. Expand: Cov⁡(U,V)=σX2−σY2, and σU2=σV2=σX2+σY2.

3. The two lines of regression

Regression fits a straight line by least squares: it minimises the sum of squared vertical (or horizontal) errors.

  • Line of y on x (predict y from x; minimises vertical errors): y−yˉ=byx(x−xˉ),byx=cov⁡(x,y)σx2=rσyσx
  • Line of x on y (predict x from y; minimises horizontal errors): x−xˉ=bxy(y−yˉ),bxy=cov⁡(x,y)σy2=rσxσy

Properties

Property Result
Product of coefficients byx bxy=r2≤1
Signs r, byx, bxy all have the same sign
r from the coefficients r=±byxbxy, sign of the coefficients
Meeting point Both lines pass through (xˉ,yˉ)
r=±1 The two lines coincide
r=0 Lines are y=yˉ and x=xˉ (perpendicular)

Given two line equations, which is which? Solve them together for (xˉ,yˉ). Then assume one is y on x and the other x on y, read byx and bxy, and check byxbxy≤1. If the product exceeds 1, swap the roles.

r2 is the coefficient of determination: the fraction of the variance of y explained by the line.

xyx̄ȳY on X (solid): slope byxless steepX on Y (dashed): slope 1/bxysteeper (r < 1)both lines meet at (x̄, ȳ)
Scatter with positive correlation: the line of y on x is less steep than the line of x on y, and both pass through the mean point.

4. Ordinary least squares and the normal equations

Given n experimental observations (xi,yi) (for example wind-tunnel angle of attack vs CL), ordinary least squares fits y=mx+c by minimizing the sum of squared vertical residuals E(m,c)=∑i=1n(yi−mxi−c)2. Setting ∂E∂c=0 and ∂E∂m=0 yields the normal equations: nc+m∑xi=∑yi,c∑xi+m∑xi2=∑xiyi.

From the first normal equation, dividing by n gives yˉ=mxˉ+c: the least-squares line always passes through the sample centroid (xˉ,yˉ). Shifting to centered sums gives the closed-form slope and intercept: m=SxySxx=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2=n∑xiyi−(∑xi)(∑yi)n∑xi2−(∑xi)2,c=yˉ−mxˉ.

Least squares minimizes ∑ eᵢ² (vertical residuals yᵢ − ŷᵢ)ŷ = mx + cresidual eᵢ = yᵢ − ŷᵢ
Ordinary least squares chooses ŷ = mx + c passing through (x̄, ȳ) to minimize the sum of squared vertical residuals eᵢ².

5. Overdetermined Ax ≈ b and nonlinear curve linearization

Normal equation in matrix form: for an overdetermined system Ax=b (m>n), the least-squares minimizer of ∣Ax−b∣2 solves (ATA) x^=ATb. Notice ATA is symmetric and invertible whenever A has full column rank.

Linearizing nonlinear aerospace laws: transform before running linear regression:

  • Induced drag polar CD=CD0+kCL2: set X=CL2,  Y=CD  ⟹  Y=kX+CD0.
  • Power law y=axb: set ln⁡y=ln⁡a+bln⁡x.
  • Exponential y=aebx: set ln⁡y=ln⁡a+bx.

Formulas to remember

Covariance (data)
cov⁡(x,y)=1n∑xiyi−xˉ yˉ
Pearson's correlation coefficientdx,dy are deviations from the means
r=cov⁡(x,y)σxσy=∑dxdy∑dx2 ∑dy2
Regression coefficient of y on x
byx=cov⁡(x,y)σx2=rσyσx
Regression coefficient of x on y
bxy=cov⁡(x,y)σy2=rσxσy
Product ruler takes the common sign of the two coefficients
r2=byx bxy
Line of y on x
y−yˉ=byx(x−xˉ)
Variance of a linear combination
Var⁡(aX+bY)=a2σX2+b2σY2+2abCov⁡(X,Y)
Spearman's rank correlation
R=1−6∑di2n(n2−1)
Normal equations
nc+m∑xi=∑yi,c∑xi+m∑xi2=∑xiyi
Least-squares slope & intercept
m=n∑xiyi−(∑xi)(∑yi)n∑xi2−(∑xi)2,c=yˉ−mxˉ

Common mistakes

  • Reading r=0 as independence: it only means no linear relation (independence implies r=0, not the other way, except for jointly Gaussian variables).
  • Predicting x from y by inverting the line of y on x; use the line of x on y.
  • Assigning the two given regression lines the wrong way round; always check byxbxy≤1.
  • Taking the positive root for r when both regression coefficients are negative; r has their sign.
  • Forgetting the 2abCov⁡(X,Y) term in the variance of a sum or difference of correlated variables.
  • Thinking a change of scale changes r; only a negative scale factor flips its sign.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Correlation and regression line from data

numerical

For the data x: 1, 2, 3, 4, 5 and y: 2, 4, 5, 4, 5, find r, the line of y on x, and the predicted y at x=6.

  1. Step 1: Find the means and the deviations.

    Try it on paper first.

Example 2: Correlation of sum and difference

numerical

X and Y are independent with σX2=4 and σY2=1. Find the correlation coefficient of U=X+Y and V=X−Y.

  1. Step 1: Expand the covariance using linearity.

    Try it on paper first.

Example 3: Fitting a least-squares line to four data points

numerical

Fit y=mx+c in the least-squares sense to (0,1),(1,3),(2,4),(3,6).

  1. Step 1: Compute sums for n = 4.

    Try it on paper first.

Example 4: Projection check on the normal matrix AᵀA

conceptual

Why is the residual vector e=b−Ax^ orthogonal to every column of A at the least-squares solution?

  1. Step 1: Rearrange the matrix normal equation.

    Try it on paper first.

Previous year questions

1 official GATE Engineering Mathematics question mapped to this topic across published papers, newest first.

Topic test

9 questions: up to 1 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 Engineering Mathematics (EC, AE, CE, EE, IN + 10 more) syllabus; being checked by a reviewer. Updated 2026-12-01. Spotted a mistake? Use Report an issue on any question, or contact us.