code: def fit(self):
          
  
          # Defaults/anchors
          best_sse = np.inf
          best_param = (0.0, 1.0)
          best_dist = scs.norm
  
          # Compute the histogram of `x`.  density=True gives a probability
          # density function at each bin, normalized such that the integral over
          # the range is 1.0
          hist, bin_edges = np.histogram(self.x, bins=self.bins, density=True)
  
          # The results of np.histogram will have len(bin_edges) = len(hist) + 1
          # Find the midpoint at each bin to reduce the size of bin_edges by 1
          bin_edges = (bin_edges + np.roll(bin_edges, -1))[:-1] / 2.0
  
          with warnings.catch_warnings():
              warnings.filterwarnings("ignore")
  
              sses = []
              params = []
  
              for dist in self.distributions:
  
                  dist = getattr(scs, dist)
  
                  try:
                      # The generic rv_continuous.fit() returns `mle_tuple`:
                      #    'MLEs for any shape parameters (if applicable),
                      #    followed by those for location and scale.'
                      param = *shape, loc, scale = dist.fit(self.x)
  
                      pdf = dist.pdf(bin_edges, loc=loc, scale=scale, *shape)
                      sse = np.sum(np.power(hist - pdf, 2.0))
  
                      sses.append(sse)
                      params.append(param)
  
                      if best_sse > sse > 0.0:
                          best_dist = dist
                          best_param = param
                          best_sse = sse
                          best_pdf = pdf
  
                  except (NotImplementedError, AttributeError):
                      sses.append(np.nan)
                      params.append(np.nan)
  
          self.best_dist = best_dist
          self.best_param = best_param
          self.best_sse = best_sse
          self.best_pdf = best_pdf
  
          self.sses = sses
          self.params = params
          self.hist = hist
          self.bin_edges = bin_edges
  
          return self
docs: Fit each distribution to `data` and calculate an SSE.
  
          WARNING: significant runtime. (~1min)