Skip to content
GATEiit

GATE EC · Engineering Mathematics

Correlation and regression analysis

Covariance, Pearson's correlation coefficient, rank correlation, the two least-squares regression lines and their properties, and correlation of random variables, with the short numericals GATE EC asks.

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.

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. Least-squares fit and rank correlation

Fitting y=a+bx by least squares. Minimising ∑(yi−a−bxi)2 gives the normal equations

∑y=na+b∑x,∑xy=a∑x+b∑x2

Their solution is exactly the line of y on x: b=byx and a=yˉ−bxˉ. Curves such as y=aebx or y=axb are fitted by taking logs first, which makes them linear in the unknowns.

Spearman's rank correlation is used when only ranks are known. Rank both variables, take di = difference of ranks for item i, and

R=1−6∑di2n(n2−1)

R also lies in [−1,1]; identical rankings give R=1 and exactly reversed rankings give R=−1. (With tied ranks, give each tied item the average rank.)

When to use what

Need Tool
Strength and sign of a linear link r
Predict y for a given x Line of y on x
Predict x for a given y Line of x on y (not the inverted y-on-x line)
Only ranks or ordinal data Spearman's R

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)

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: Identifying the two regression lines

numerical

The two regression lines of a bivariate data set are 4x−5y+13=0 and 20x−9y=15. Find xˉ, yˉ and r. If σx=3, find σy.

  1. Step 1: Solve the two equations together.

    Try it on paper first.

Example 3: 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 4: Uncorrelated but not independent

conceptual

X takes the values −1,0,1 with equal probability and Y=X2. Are X and Y correlated? Are they independent?

  1. Step 1: Compute $E[X]$, $E[XY]$ and the covariance.

    Try it on paper first.

Previous year questions

1 official GATE EC question on this topic, 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 EC syllabus; being checked by a reviewer. Updated 2026-11-29. Spotted a mistake? Use Report an issue on any question, or contact us.