code: def multinomial_like(x, n, p):
      R
      # flib expects 2d arguments. Do we still want to support multiple p
      # values along realizations ?
      x = np.atleast_2d(x)
      p = np.atleast_2d(p)
  
      return flib.multinomial(x, n, p)
docs: R"""
      Multinomial log-likelihood.
  
      Generalization of the binomial
      distribution, but instead of each trial resulting in "success" or
      "failure", each one results in exactly one of some fixed finite number k
      of possible outcomes over n independent trials. 'x[i]' indicates the number
      of times outcome number i was observed over the n trials.
  
      .. math::
          f(x \mid n, p) = \frac{n!}{\prod_{i=1}^k x_i!} \prod_{i=1}^k p_i^{x_i}
  
      :Parameters:
        x : (ns, k) int
            Random variable indicating the number of time outcome i is
            observed. :math:`\sum_{i=1}^k x_i=n`, :math:`x_i \ge 0`.
        n : int
            Number of trials.
        p : (k,)
            Probability of each one of the different outcomes.
            :math:`\sum_{i=1}^k p_i = 1)`, :math:`p_i \ge 0`.
  
      .. note::
         - :math:`E(X_i)=n p_i`
         - :math:`Var(X_i)=n p_i(1-p_i)`
         - :math:`Cov(X_i,X_j) = -n p_i p_j`
         - If :math:`\sum_i p_i < 0.999999` a log-likelihood value of -inf
         will be returned.