code: def erf(z):
      
      # Input check
      try:
          len(z)
      except TypeError:
          scalar = True
          z = [z]
      else:
          scalar = False
  
      z = numpy.array(z)
  
      # Begin algorithm
      t = 1.0 / (1.0 + 0.5 * numpy.abs(z))
  
      # Use Horner's method
      ans = 1 - t * numpy.exp(
          -z * z - 1.26551223 + t * (
              1.00002368 + t * (0.37409196 + t * (
                  0.09678418 + t * (
                      -0.18628806 + t * (
                          0.27886807 + t * (
                              -1.13520398 + t * (
                                  1.48851587 + t * (
                                      -0.82215223 + t * 0.17087277)))))))))
  
      neg = (z < 0.0)  # Mask for negative input values
      ans[neg] = -ans[neg]
  
      if scalar:
          return ans[0]
      else:
          return ans
docs: Approximation to ERF.
  
      :param z: Input array or scalar to perform erf on.
      :type z: numpy.ndarray, float
  
      :returns: The approximate error.
      :rtype: numpy.ndarray, float
  
      Note:
          from:
          http://www.cs.princeton.edu/introcs/21function/ErrorFunction.java.html
          Implements the Gauss error function.
          erf(z) = 2 / sqrt(pi) * integral(exp(-t*t), t = 0..z)
  
          Fractional error in math formula less than 1.2 * 10 ^ -7.
          although subject to catastrophic cancellation when z in very close to 0
          from Chebyshev fitting formula for erf(z) from Numerical Recipes, 6.2
  
          Source:
          http://stackoverflow.com/questions/457408/
          is-there-an-easily-available-implementation-of-erf-for-python