12
I need to implement a linear regression algorithm. Preferably that gives equal or near results to the function TENDENCY (or TREND) excel.
I’ve found a lot of material that tries to explain the whole concept of linear regression, but that’s not what I want. I would like a pseudo code that is directly translatable for an imperative programming language.
For those who didn’t use the function TENDENCY it works like this:
Data 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 a value of x for which you want to find out the corresponding value of y, the function TENDENCY fits the known values in a function of the form y=mx+b and gives you the value of y. In this case if I pass the value 5 as the last argument, the function returns me 50.
Someone might give a pseudo code from an algorithm that does this?
Dude, I did it in college over 10 years ago, but I can’t remember (nor find references). I’m also looking for something like this. In this blog post there is a very simple implementation in Python - but according to the author it is more "didactic" than "efficient" (after all, there are zillions of ways to make linear regression, each with its pros and cons).
– mgibsonbr