<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def loglike(self, endog, mu, freq_weights=1., scale=1.):
 """ The log-likelihood in terms of the fitted mean response. 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 Scales the loglikelihood function. The default is 1. Returns ------- llf : float The value of the loglikelihood function evaluated at (endog,mu,freq_weights,scale) as defined below. """

        if isinstance(self.link, L.Power) and self.link.power == 1:
            # This is just the loglikelihood for classical OLS
            nobs2 = endog.shape[0] / 2.
            SSR = np.sum((endog-self.fitted(mu))**2, axis=0)
            llf = -np.log(SSR) * nobs2
            llf -= (1+np.log(np.pi/nobs2))*nobs2
            return llf
        else:
            return np.sum(freq_weights * ((endog * mu - mu**2/2)/scale -
                          endog**2/(2 * scale) - .5*np.log(2 * np.pi * scale)))