def resid_dev(self, endog, mu, scale=1.):
        r"""Poisson deviance residual

        Parameters
        ----------
        endog : array-like
            Endogenous response variable
        mu : array-like
            Fitted mean response variable
        scale : float, optional
            An optional argument to divide the residuals by scale. The default
            is 1.

        Returns
        -------
        resid_dev : array
            Deviance residuals as defined below

        Notes
        -----
        .. math::

           resid\_dev_i = sign(Y_i - \mu_i) * \sqrt{2 *
                          (Y_i * \log(Y_i / \mu_i) - (Y_i - \mu_i))} / scale
        """
        endog_mu = self._clean(endog / mu)
        return (np.sign(endog - mu) *
                np.sqrt(2 * (endog * np.log(endog_mu) - (endog - mu))) / scale)
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/genmod/families/family.py/Poisson.resid_dev/original