I was trying to write a vectorized notation for the iterative process of converging theta values in gradient descent algorithm. I found the vector notation but for some reason, the values are not converging. I've tried with a lot of different values for alpha but none of them seem to work. Any help is appreciated. Thank you !
X=[1,2104,5,1,45;1,1416,3,2,40;1,1534,3,2,30;1,852,2,1,36]
y=[460;232;315;178]
m=size(X,1)
alpha=0.01
n+1=size(X,2)
theta=zeros(n+1,1)
for it=1:100,
theta=theta-((alpha/m)*(X'*((X*theta)-y)))
end;
disp(theta)
It's supposed to yield a result of theta values but it throws some values for a few iterations and then goes to Nan. Also the values before Nan are nowhere close to the ones I got from Normal equations method.