def deviance(self, endog, mu, freq_weights=1, scale=1.):
        r'''
        Deviance function for either Bernoulli or Binomial data.

        Parameters
        ----------
        endog : array-like
            Endogenous response variable (already transformed to a probability
            if appropriate).
        mu : array
            Fitted mean response variable
        freq_weights : array-like
            1d array of frequency weights. The default is 1.
        scale : float, optional
            An optional scale argument. The default is 1.

        Returns
        --------
        deviance : float
            The deviance function as defined below

        Notes
        -----
        If the endogenous variable is binary:

        .. math::

           D = -2 * \sum_i freq\_weights * (I_{1,i} * \log(\mu_i) + I_{0,i} *
               \log(1 - \mu_i))

        where :math:`I_{1,i}` is an indicator function that evalueates to 1 if
        :math:`Y_i = 1`. and :math:`I_{0,i}` is an indicator function that
        evaluates to 1 if :math:`Y_i = 0`.

        If the model is ninomial:

        .. math::

           D = 2 * \sum_i freq\_weights * (\log(Y_i / \mu_i) + (n_i - Y_i) *
               \log((n_i - Y_i) / n_i - \mu_i))

        where :math:`Y_i` and :math:`n` are as defined in Binomial.initialize.
        '''
        if np.shape(self.n) == () and self.n == 1:
            one = np.equal(endog, 1)
            return -2 * np.sum((one * np.log(mu + 1e-200) + (one-1) *
                               np.log(1 - mu + 1e-200)) * freq_weights)

        else:
            return 2 * np.sum(self.n * freq_weights *
                              (endog * np.log(endog/mu + 1e-200) +
                               (1 - endog) * np.log((1 - endog) /
                               (1 - mu) + 1e-200)))
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/genmod/families/family.py/Binomial.deviance/swapped operands of `-`