Linear Regression Method Pseudocode
In Linear Regression Method Algorithm we discussed about an algorithm for linear regression and procedure for least sqaure method. In this article we are going to develop pseudocode for Linear Regression Method so that it will be easy while implementing this method using high level programming languages.
Pseudocode for Linear Regression
1. Start 2. Read Number of Data (n) 3. For i=1 to n: Read Xi and Yi Next i 4. Initialize: sumX = 0 sumX2 = 0 sumY = 0 sumXY = 0 5. Calculate Required Sum For i=1 to n: sumX = sumX + Xi sumX2 = sumX2 + Xi * Xi sumY = sumY + Yi sumXY = sumXY + Xi * Yi Next i 6. Calculate Required Constant a and b of y = a + bx: b = (n * sumXY - sumX * sumY)/(n*sumX2 - sumX * sumX) a = (sumY - b*sumX)/n 7. Display value of a and b 8. Stop