Correlation, regression and stochastic processes — Unit 5 Notes (Probability and Statistics for Computing)

BAS401 · Unit 5

Correlation, regression and stochastic processes notes — Unit 5

Free unit-wise study notes on correlation, regression and stochastic processes for Probability and Statistics for Computing, Semester 4 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.

Relationships between variables and time. Covers Bivariate data, Pearson's Correlation Coefficient, the mathematical derivation of Linear Regression, and an introduction to Random Processes, particularly the Markov Chain.

Notebook — 8 pages

Page 1

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

1. Bivariate Data and Covariance

Until now, we analyzed a single random variable isolated by itself. In data science, we usually analyze two variables simultaneously (Bivariate Data) to see if they influence each other. (e.g., Does more CPU clock speed XX result in higher temperature YY?)

1.1 Covariance

Covariance measures how two variables vary together. If XX goes up, does YY usually go up (positive covariance)? Or does YY go down (negative covariance)?

Formula: Cov(X,Y)=E[(Xμx)(Yμy)]=E[XY]E[X]E[Y]Cov(X, Y) = E[(X - \mu_x)(Y - \mu_y)] = E[XY] - E[X]E[Y]

The Flaw: Covariance is highly sensitive to physical units. If you measure XX in grams instead of kilograms, the Covariance explodes by a factor of 1000, even though the underlying physical relationship is identical. This makes raw Covariance practically useless for judging the "strength" of a relationship.

Next — Pearson Correlation Coefficient

1 of 8

Page 2

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

2. Pearson Correlation Coefficient ($r$)

To fix the unit flaw of Covariance, we divide it by the standard deviations of both variables. This mathematically standardizes the metric, removing all physical units.

The result is Pearson's Correlation Coefficient, denoted as ρ\rho (rho) for the population, and rr for a sample.

Formula: r=Cov(X,Y)σxσyr = \frac{Cov(X, Y)}{\sigma_x \sigma_y}

2.1 Properties of rr

  • The value of rr is strictly bounded: 1r1-1 \le r \le 1.
  • r=1r = 1: Perfect positive linear relationship. All data points fall exactly on a straight line sloping upward.
  • r=1r = -1: Perfect negative linear relationship. Line slopes downward.
  • r=0r = 0: Absolutely no LINEAR relationship. (Warning: The variables might still have a perfect curved/quadratic relationship. Pearson only detects straight lines).

Correlation does NOT imply Causation. A high rr value between Ice Cream Sales and Shark Attacks does not mean ice cream causes sharks to attack; they are both driven by a third hidden variable (Summer heat).

Next — Linear Regression

2 of 8

Page 3

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

3. Linear Regression (Lines of Best Fit)

Correlation tells us if a linear relationship exists. Regression allows us to mathematically construct the exact equation of that line, allowing us to predict future values of YY based on new inputs of XX.

3.1 The Equation

We want to find the best straight line: Y=a+bXY = a + bX

Where:
-
YY is the Dependent variable (the one we want to predict).
-
XX is the Independent variable (the input).
-
bb is the slope of the line (Regression Coefficient).
-
aa is the Y-intercept.

But if we have a scatterplot of 50 noisy data points, no single straight line can perfectly hit all of them. How do we define which line is mathematically the "best"?

Next — Method of Least Squares

3 of 8

Page 4

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

4. The Method of Least Squares

Invented by Carl Friedrich Gauss, this is the algorithmic foundation of all machine learning model training.

4.1 Minimizing Error

For any line we draw, there will be an Error (or Residual) between our line's prediction and the actual true data point.
Errori=YactualYpredicted=Yi(a+bXi)Error_i = Y_{actual} - Y_{predicted} = Y_i - (a + bX_i)

Some errors are positive (above the line), some are negative (below). We square them to make them all positive and heavily penalize massive outliers.

The "Best Fit" line is defined as the specific line that minimizes the Sum of Squared Errors (SSE):
Minimize S(a,b)=i=1n(YiabXi)2S(a, b) = \sum_{i=1}^{n} (Y_i - a - bX_i)^2

4.2 The Normal Equations

To find the minimum, we use partial differential calculus. We take the partial derivative of SS with respect to aa, set it to 0. Then take the partial derivative with respect to bb, and set it to 0.
This yields a system of two linear equations (The Normal Equations):

Y=na+bX\sum Y = n \cdot a + b \sum X
XY=aX+bX2\sum XY = a \sum X + b \sum X^2

Solving these two equations yields the perfect, mathematically optimal values for the slope bb and intercept aa.

Next — Stochastic Processes Introduction

4 of 8

Page 5

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

5. Introduction to Stochastic Processes

Until now, random variables were static. A Stochastic (Random) Process introduces the dimension of Time. It is a collection of random variables indexed by time, representing a system that evolves probabilistically.

Notation: {X(t),tT}\{X(t), t \in T\}

If TT is discrete (Time steps 1, 2, 3...), it is a Discrete-Time process. (e.g., The closing price of a stock at the end of each day).
If
TT is continuous, it is a Continuous-Time process. (e.g., The exact temperature of a CPU recorded every microsecond).

The set of all possible values the process can take is called the State Space.

Next — The Markov Property

5 of 8

Page 6

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

6. Markov Chains and the Markov Property

Analyzing a system where the future depends on a long, complex history of past events is mathematically paralyzing.

Andrey Markov introduced a simplification: The Markov Property (Memorylessness).

6.1 The Definition

A stochastic process is a Markov Chain if the probability distribution of the next state depends exclusively and entirely on the current state, and is completely independent of the sequence of events that preceded it.

"The future is independent of the past, given the present."

Mathematically:
P(Xn+1=jXn=i,Xn1=k,...,X0=m)=P(Xn+1=jXn=i)P(X_{n+1} = j \mid X_n = i, X_{n-1} = k, ..., X_0 = m) = P(X_{n+1} = j \mid X_n = i)

Next — Transition Probability Matrix

6 of 8

Page 7

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

7. Transition Probability Matrix

Because a Markov Chain only cares about moving from the current state ii to the next state jj, we can define the entire system using simple transition probabilities: PijP_{ij}.

7.1 The Matrix (P)

We organize all possible transitions into a square matrix PP. If the system has 3 states, it is a 3×33 \times 3 matrix.

P=[P00P01P02P10P11P12P20P21P22]P = \begin{bmatrix} P_{00} & P_{01} & P_{02} \\ P_{10} & P_{11} & P_{12} \\ P_{20} & P_{21} & P_{22} \end{bmatrix}

The element P12P_{12} represents the probability of jumping to state 2, assuming you are currently in state 1.

Crucial Property: Because you MUST go somewhere in the next time step (even if you just stay in the same state), the sum of probabilities in every single row MUST equal exactly 1. (It is a Stochastic Matrix).

Next — Summary Checklist

7 of 8

Page 8

Wink Notes

B.Tech CSE — 4th Semester

Probability and Statistics

Unit - 5

8. Summary Checklist

Unit 5 covers the practical tools used in modern data modeling.

8.1 University Exam Checklist

  • Calculate the Covariance of two datasets. Explain why Covariance is flawed.
  • Calculate Pearson's Correlation Coefficient (rr) for a given dataset.
  • Explain the difference between r=0r=0, r=1r=1, and r=1r=-1. Why does r=0r=0 not imply complete independence?
  • Explain the Method of Least Squares. What mathematical function is being minimized?
  • Write down the two Normal Equations used to find the slope and intercept of the regression line.
  • Use the Normal Equations to calculate the line of best fit (Y=a+bXY = a + bX) for a table of 5 data points.
  • Define a Stochastic Process. What is the difference between discrete-time and continuous-time?
  • State the Markov Property mathematically and in plain English.
  • Construct a Transition Probability Matrix given a word problem (e.g., weather prediction). What property must every row of the matrix satisfy?

8 of 8

Continue in this subject