code: def _ipsi(y, tol=1.48e-9, maxiter=10):
      '''Inverse of psi (digamma) using Newton's method. For the purposes
      of Dirichlet MLE, since the parameters a[i] must always
      satisfy a > 0, we define ipsi :: R -> (0,inf).'''
      y = asanyarray(y, dtype='float')
      x0 = _piecewise(y, [y >= -2.22, y < -2.22],
              [(lambda x: exp(x) + 0.5), (lambda x: -1/(x+euler))])
      for i in xrange(maxiter):
          x1 = x0 - (psi(x0) - y)/_trigamma(x0)
          if norm(x1 - x0) < tol:
              return x1
          x0 = x1
      raise Exception(
          'Unable to converge in {} iterations, value is {}'.format(maxiter, x1)f _ipsi(y, tol=1.48e-9, maxiter=10):
      '''Inverse of psi (digamma) using Newton's method. For the purposes
      of Dirichlet MLE, since the parameters a[i] must always
      satisfy a > 0, we define ipsi :: R -> (0,inf).'''
      y = asanyarray(y, dtype='float')
      x0 = _piecewise(y, [y >= -2.22, y < -2.22],
              [(lambda x: exp(x) + 0.5), (lambda x: -1/(x+euler))])
      for i in xrange(maxiter):
          x1 = x0 - (psi(x0) - y)/_trigamma(x0)
          if norm(x1 - x0) < tol:
              return x1
          x0 = x1
      raise Exception(
          'Unable to converge in {} iterations, value is {}'.format(maxiter, x1))
docs: Inverse of psi (digamma) using Newton's method. For the purposes
      of Dirichlet MLE, since the parameters a[i] must always
      satisfy a > 0, we define ipsi :: R -> (0,inf).