I need to implement a linear regression algorithm. Preferably, it gives results that are the same as or close to the TREND (or TREND ) function of Excel.
I have already found a lot of material that attempts to explain the whole concept of linear regression, but that is not what I want. I would like a pseudo code that is directly translatable for an imperative programming language.
For those who did not use the TENDENCY function, it works like this:
Given two vectors representing x and y, in an ordered pair (x, y), for known values, for example, [1,10], (2,20), (3,30), (4.40)] , and an x value for which you want to find the corresponding y value, the TREND function fits the known values in a function of the form y = mx + b gives you the value of y. In this case if I pass the value 5 as the last argument, the function returns me 50.
Is anyone able to give a pseudo code an algorithm that does this?