public static double sumSquaredError(double[] a,double[] b){
  if (a.length != b.length) {
    throw new IllegalArgumentException("Arrays must be equal length");
  }
  double sum=0;
  for (int i=0; i < a.length; i++) {
    double delta=a[i] - b[i];
    if (!Double.isNaN(delta)) {
      sum+=delta * delta;
    }
  }
  return sum;
}

public static double sumSquaredError ( double [ ] a , double [ ] b ) { if ( a . length != b . length ) { throw new IllegalArgumentException ( "Arrays must be equal length" ) ; } double sum = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { double delta = a [ i ] - b [ i ] ; if ( ! Double . isNaN ( delta ) ) { sum += delta * delta ; } } return sum ; }
build the sum of the squared difference of all elements with the same index numbers in the arrays . any nan values in either a or b are ignored in computing the error .
