I was trying to implement linear regression with gradient descent using the equation presented on the machine learning course on Coursera:
However when I run it doesn't converge to the real values:
I guess I implemented something wrong, I just cannot find it. I was looking for other papers on the internet and found different implementations for gradient descent, such as:
(found at: http://cs229.stanford.edu/notes/cs229-notes1.pdf)
The main question is where could be the problem in my algorithm. On the other hand it would be good to know why there is a different equation for solving the problem.
Update: I removed the code snippet as it was irrelevant. I realized the algorithm works fine, what you can see on the image is just simply the lack of iterations. If you take 10000 iterations it almost perfectly fits the right result set.