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
        -----
        When :math:`p = 1`,

        .. math::

            resid\_dev_i = \mu

        when :math:`endog = 0` and

        .. math::

            resid\_dev_i = endog * \log(endog / \mu) + (\mu - endog)

        otherwise.

        When :math:`p = 2`,

        .. math::

            resid\_dev_i =  (endog - \mu) / \mu - \log(endog / \mu)

        For all other p,

        .. math::

            resid\_dev_i = endog ^{2 - p} / ((1 - p) * (2 - p)) -
                           endog * \mu ^{1 - p} / (1 - p) + \mu ^{2 - p} /
                           (2 - p)

        Once :math:`resid\_dev_i` is calculated, then calculate deviance as

        .. math::

            D = \sum{2 * freq\_weights * resid\_dev_i}
        """
        p = self.var_power
        if p == 1:
            dev = np.where(endog == 0,
                           mu,
                           endog * np.log(endog / mu) + (mu - endog))
        elif p == 2:
            endog1 = np.clip(endog, FLOAT_EPS, np.inf)
            dev = ((endog - mu) / mu) - np.log(endog1 / mu)
        else:
            dev = (((1 - p) * (2 - p)) / endog ** (2 - p) -
                   endog * mu ** (1-p) / (1 - p) + mu ** (2 - p) / (2 - p))
        return np.sum(2 * freq_weights * dev)
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/genmod/families/family.py/Tweedie.deviance/swapped operands of `/`