Skip to content

Instantly share code, notes, and snippets.

@digorithm
Created January 9, 2015 00:28
Show Gist options
  • Save digorithm/9fc7a2aaf613c1b2074a to your computer and use it in GitHub Desktop.
Save digorithm/9fc7a2aaf613c1b2074a to your computer and use it in GitHub Desktop.
public void execute(){
do {
this.theta1 -= alpha * deriveTheta1();
this.theta0 -= alpha * deriveTheta0();
//used for plotting
tplot[iters] = iters;
theta0plot[iters] = theta0;
theta1plot[iters] = theta1;
iters++;
if (iters % dispiter == 0){
addTrendLine(plot, true);
}
if (iters > maxiter) break;
} while (Math.abs(theta1) > tol || Math.abs(theta0) > tol);
plot.addScatterPlot("X-Y", initial_data.x, initial_data.y);
System.out.println("theta0 = " + this.theta0 + " and theta1 = " + this.theta1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment