code: def fit_maxlike(x, r_guess):
      # follows Wikipedia's section on negative binomial max likelihood
      assert np.var(x) > np.mean(
          x
      ), "Likelihood-maximizing parameters don't exist!"
      loglike = lambda r, p: np.sum(negbin_loglike(r, p, x))
      p = lambda r: np.sum(x) / np.sum(r + x)
      rprime = lambda r: grad(loglike)(r, p(r))
      r = newton(rprime, r_guess)
      return r, p(r)
  
file_path: autograd/examples/negative_binomial_maxlike.py
imports: from __future__ import division, print_function
  import autograd.numpy
  import autograd.numpy.random
  from autograd.scipy.special import gammaln
  from autograd import grad
  import scipy.optimize
label_desc: Use image node_id 4 for calling a global function with example usage: fit_maxlike(x, r_guess) and returns: r,  p