public static double squaredLoss(double[] x,double[] y,double w_0,double w_1){
  double sum=0;
  for (int j=0; j < x.length; j++) {
    sum+=Math.pow((y[j] - (w_1 * x[j] + w_0)),2);
  }
  return sum;
}

public static double squaredLoss ( double [ ] x , double [ ] y , double w_0 , double w_1 ) { double sum = 0 ; for ( int j = 0 ; j < x . length ; j ++ ) { sum += Math . pow ( ( y [ j ] - ( w_1 * x [ j ] + w_0 ) ) , 2 ) ; } return sum ; }
this will return the squared loss of the given points
