Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. x = [1, 2.07; 1, 2.37; 1, 2.54];
  2. y = [0.779; 0.916; 0.905];
  3. %x = load('ex2x.dat');
  4. %y = load('ex2y.dat');
  5. m = length(y);
  6. %x = [ones(m, 1), x];
  7. theta = [0.0;0.0];
  8. alpha = 0.0002;
  9. for k=1:2000,
  10. acc = 0.0;
  11. for j = 1:m,
  12. acc = ((theta'*x(j,:)'-y(j,1))*x(j,:))'+acc;
  13. end
  14. theta = theta - (alpha / m)*acc;
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement