code: def phi_inv(p):
      
      if p < 0.5:
          t = math.sqrt(-2.0*math.log(p))
          return ((0.010328*t + 0.802853)*t + 2.515517)/(((0.001308*t + 0.189269)*t + 1.432788)*t + 1.0) - t
      else:
          t = math.sqrt(-2.0*math.log(1.0-p))
          return t - ((0.010328*t + 0.802853)*t + 2.515517)/(((0.001308*t + 0.189269)*t + 1.432788)*t + 1.0)
docs: phi_inv: inverse of gaussian (normal) CDF
      Source:
          Handbook of Mathematical Functions
          Dover Books on Mathematics
          Milton Abramowitz and Irene A. Stegun (Editors)
          Formula 26.2.23.