code: def erfinv(z):
      
      if abs(z) > 1:
          raise ValueError("`z` must be between -1 and 1 inclusive")
  
      # Shortcut special cases
      if z == 0:
          return 0
      if z == 1:
          return inf
      if z == -1:
          return -inf
  
      # otherwise calculate things.
      return _ndtri((z + 1) / 2.0) / math.sqrt(2)
docs: Calculate the inverse error function at point ``z``.
  
      This is a direct port of the SciPy ``erfinv`` function, originally
      written in C.
  
      Parameters
      ----------
      z : numeric
  
      Returns
      -------
      float
  
      References
      ----------
      + https://en.wikipedia.org/wiki/Error_function#Inverse_functions
      + http://functions.wolfram.com/GammaBetaErf/InverseErf/
  
      Examples
      --------
      >>> round(erfinv(0.1), 12)
      0.088855990494
      >>> round(erfinv(0.5), 12)
      0.476936276204
      >>> round(erfinv(-0.5), 12)
      -0.476936276204
      >>> round(erfinv(0.95), 12)
      1.38590382435
      >>> round(erf(erfinv(0.3)), 3)
      0.3
      >>> round(erfinv(erf(0.5)), 3)
      0.5
      >>> erfinv(0)
      0
      >>> erfinv(1)
      inf
      >>> erfinv(-1)
      -inf