public static double erf(double x) {
    final double w = x < 0 ? -x : x;
    double y;
    if(w < 2.2) {
      double t = w * w;
      int k = (int) t;
      t -= k;
      k *= 13;
      y = ((((((((((((ERF_COEFF1[k] * t + ERF_COEFF1[k + 1]) * t + //
          ERF_COEFF1[k + 2]) * t + ERF_COEFF1[k + 3]) * t + ERF_COEFF1[k + 4]) * t + //
          ERF_COEFF1[k + 5]) * t + ERF_COEFF1[k + 6]) * t + ERF_COEFF1[k + 7]) * t + //
          ERF_COEFF1[k + 8]) * t + ERF_COEFF1[k + 9]) * t + ERF_COEFF1[k + 10]) * t + //
          ERF_COEFF1[k + 11]) * t + ERF_COEFF1[k + 12]) * w;
    }
    else if(w < 6.9) {
      int k = (int) w;
      double t = w - k;
      k = 13 * (k - 2);
      y = (((((((((((ERF_COEFF2[k] * t + ERF_COEFF2[k + 1]) * t + //
          ERF_COEFF2[k + 2]) * t + ERF_COEFF2[k + 3]) * t + ERF_COEFF2[k + 4]) * t + //
          ERF_COEFF2[k + 5]) * t + ERF_COEFF2[k + 6]) * t + ERF_COEFF2[k + 7]) * t + //
          ERF_COEFF2[k + 8]) * t + ERF_COEFF2[k + 9]) * t + ERF_COEFF2[k + 10]) * t + //
          ERF_COEFF2[k + 11]) * t + ERF_COEFF2[k + 12];
      y *= y;
      y *= y;
      y *= y;
      y = 1 - y * y;
    }
    else if(w == w) {
      y = 1;
    }
    else {
      return Double.NaN;
    }
    return x < 0 ? -y : y;
  }
public static double erf ( double x ) { final double w = x < 0 ? - x : x ; double y ; if ( w < 2.2 ) { double t = w * w ; int k = ( int ) t ; t -= k ; k *= 13 ; y = ( ( ( ( ( ( ( ( ( ( ( ( ERF_COEFF1 [ k ] * t + ERF_COEFF1 [ k + 1 ] ) * t + ERF_COEFF1 [ k + 2 ] ) * t + ERF_COEFF1 [ k + 3 ] ) * t + ERF_COEFF1 [ k + 4 ] ) * t + ERF_COEFF1 [ k + 5 ] ) * t + ERF_COEFF1 [ k + 6 ] ) * t + ERF_COEFF1 [ k + 7 ] ) * t + ERF_COEFF1 [ k + 8 ] ) * t + ERF_COEFF1 [ k + 9 ] ) * t + ERF_COEFF1 [ k + 10 ] ) * t + ERF_COEFF1 [ k + 11 ] ) * t + ERF_COEFF1 [ k + 12 ] ) * w ; } else if ( w < 6.9 ) { int k = ( int ) w ; double t = w - k ; k = 13 * ( k - 2 ) ; y = ( ( ( ( ( ( ( ( ( ( ( ERF_COEFF2 [ k ] * t + ERF_COEFF2 [ k + 1 ] ) * t + ERF_COEFF2 [ k + 2 ] ) * t + ERF_COEFF2 [ k + 3 ] ) * t + ERF_COEFF2 [ k + 4 ] ) * t + ERF_COEFF2 [ k + 5 ] ) * t + ERF_COEFF2 [ k + 6 ] ) * t + ERF_COEFF2 [ k + 7 ] ) * t + ERF_COEFF2 [ k + 8 ] ) * t + ERF_COEFF2 [ k + 9 ] ) * t + ERF_COEFF2 [ k + 10 ] ) * t + ERF_COEFF2 [ k + 11 ] ) * t + ERF_COEFF2 [ k + 12 ] ; y *= y ; y *= y ; y *= y ; y = 1 - y * y ; } else if ( w == w ) { y = 1 ; } else { return Double . NaN ; } return x < 0 ? - y : y ; }
Error function for Gaussian distributions = Normal distributions.

@param x parameter value
@return erf(x)