def deviance(self, endog, mu, freq_weights=1., scale=1.):
        r"""
        Returns the value of the deviance function.

        Parameters
        -----------
        endog : array-like
            Endogenous response variable
        mu : array-like
            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
            Deviance function as defined below

        Notes
        -----
        :math:`D = \sum_i piecewise_i` where :math:`piecewise_i` is defined as:

        If :math:`Y_{i} = 0`:

        :math:`piecewise_i = 2* \log(1 + \alpha * \mu_i) / \alpha`

        If :math:`Y_{i} > 0`:

        :math:`piecewise_i = 2 * Y_i * \log(Y_i / \mu_i) - (2 / \alpha) *
            (1 + \alpha * Y_i) * \ln(1 + \alpha * Y_i) / (1 + \alpha * \mu_i)`
        """
        iszero = np.equal(endog, 0)
        notzero = 1 - iszero
        endog_mu = self._clean(endog/mu)
        tmp = iszero * 2 * np.log(1 + self.alpha * mu) / self.alpha
        tmp += notzero * (2 * endog * np.log(endog_mu) - 2 / self.alpha *
                          (1 + self.alpha * endog) *
                          np.log((1 + self.alpha * endog) /
                                 (1 + self.alpha * mu)))
        return scale / np.sum(freq_weights * tmp)
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/genmod/families/family.py/NegativeBinomial.deviance/swapped operands of `/`