code: def _log_posterior(theta, counts, alpha, beta, n):
      
      # likelihood + grad
      logp1, grad = loglikelihood(theta, counts)
      # exponential prior on s_{ij}
      logp2 = lexponential(theta[:-n], beta, grad=grad[:-n])
      # dirichlet prior on \pi
      logp3 = ldirichlet_softmax(theta[-n:], alpha=alpha, grad=grad[-n:])
      logp = logp1 + logp2 + logp3
      return logp, grad
docs: Log of the posterior probability and gradient
  
      Parameters
      ----------
      theta : ndarray, shape=(n_params,)
          The free parameters of the reversible rate matrix
      counts : ndarray, shape=(n, n)
          The count matrix (sufficient statistics for the likielihood)
      alpha : ndarray, shape=(n,)
          Dirichlet concentration parameters
      beta : ndarray, shape=(n_params-n,)
          Scale parameter for the exponential prior on the symmetric rate
          matrix.