private void validateCoefficients ( ) { if ( coefsValid ) return ; if ( n >= 2 ) { double xBar = ( double ) sumX / n ; double yBar = ( double ) sumY / n ; a1 = ( double ) ( ( n * sumXY - sumX * sumY ) / ( n * sumXX - sumX * sumX ) ) ; a0 = ( double ) ( yBar - a1 * xBar ) ; } else { a0 = a1 = Double . NaN ; } coefsValid = true ; }
Validate the coefficients .