'Gradient Descent for Linear Regression in One Variable(Octave)

Can anybody give a detailed explaination on how this piece of code works?

h=(theta' * X')';
theta = theta -((1/m) * (h - y)' * X)' * alpha;

*where X is the feature vector. *y is the output vector. *m is the number of training examples.

I couldn't get the optimal values when I did in this way:

temp0 = theta(1) - alpha * (1/m) * sum((X * theta) - y);
temp1 = theta(2) - alpha * (1/m) * sum(((X * theta) - y )* X(m,2));
theta(1) = temp0;
theta(2) = temp1;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source