<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fit(self):
 r"""Loop over distributions and find best parameter to fit the data for each When a distribution is fitted onto the data, we populate a set of dataframes: - :attr:`df_errors` :sum of the square errors between the data and the fitted distribution i.e., :math:`\sum_i \left( Y_i - pdf(X_i) \right)^2` - :attr:`fitted_param` : the parameters that best fit the data - :attr:`fitted_pdf` : the PDF generated with the parameters that best fit the data Indices of the dataframes contains the name of the distribution. """

        for distribution in self.distributions:
            try:
                # need a subprocess to check time it takes. If too long, skip it
                dist = eval("scipy.stats." + distribution)

                # TODO here, dist.fit may take a while or just hang forever
                # with some distributions. So, I thought to use signal module
                # to catch the error when signal takes too long. It did not work
                # presumably because another try/exception is inside the
                # fit function, so I used threading with arecipe from stackoverflow
                # See timed_run function above
                param = self._timed_run(dist.fit, distribution, args=self._data)

                # with signal, does not work. maybe because another expection is caught
                pdf_fitted = dist.pdf(self.x, *param) # hoping the order returned by fit is the same as in pdf

                self.fitted_param[distribution] = param[:]
                self.fitted_pdf[distribution] = pdf_fitted

                sq_error = pylab.sum((self.fitted_pdf[distribution] - self.y)**2)
                if self.verbose:
                    print("Fitted {} distribution with error={})".format(distribution, sq_error))

                # compute some errors now
                self._fitted_errors[distribution] = sq_error
            except Exception as err:
                if self.verbose:
                    print("SKIPPED {} distribution (taking more than {} seconds)".format(distribution, 
                        self.timeout))
                # if we cannot compute the error, set it to large values
                # FIXME use inf
                self._fitted_errors[distribution] = 1e6

        self.df_errors = pd.DataFrame({'sumsquare_error':self._fitted_errors})