code: def power_law_fit(data, xmin=None, method="auto", p_precision=0.01):
      """Fitting a power-law distribution to empirical data
  
      B{References}
  
        - MEJ Newman: Power laws, Pareto distributions and Zipf's law.
          I{Contemporary Physics} 46, 323-351 (2005)
        - A Clauset, CR Shalizi, MEJ Newman: Power-law distributions
          in empirical data. E-print (2007). arXiv:0706.1062
  
      @param data: the data to fit, a list containing integer values
      @param xmin: the lower bound for fitting the power-law. If C{None},
        the optimal xmin value will be estimated as well. Zero means that
        the smallest possible xmin value will be used.
      @param method: the fitting method to use. The following methods are
        implemented so far:
  
          - C{continuous}, C{hill}: exact maximum likelihood estimation
            when the input data comes from a continuous scale. This is
            known as the Hill estimator. The statistical error of
            this estimator is M{(alpha-1) / sqrt(n)}, where alpha is the
            estimated exponent and M{n} is the number of data points above
            M{xmin}. The estimator is known to exhibit a small finite
            sample-size bias of order M{O(n^-1)}, which is small when
            M{n > 100}. igraph will try to compensate for the finite sample
            size if n is small.
  
          - C{discrete}: exact maximum likelihood estimation when the
            input comes from a discrete scale (see Clauset et al among the
            references).
  
          - C{auto}: exact maximum likelihood estimation where the continuous
            method is used if the input vector contains at least one fractional
            value and the discrete method is used if the input vector contains
            integers only.
      @param p_precision: desired precision of the p-value calculation. The
        precision ultimately depends on the number of resampling attempts. The
        number of resampling trials is determined by 0.25 divided by the square
        of the required precision. For instance, a required precision of 0.01
        means that 2500 samples will be drawn.
  
      @return: a L{FittedPowerLaw} object. The fitted C{xmin} value and the
        power-law exponent can be queried from the C{xmin} and C{alpha}
        properties of the returned object.
      """
      from igraph._igraph import _power_law_fit
  
      if xmin is None or xmin < 0:
          xmin = -1
  
      method = method.lower()
      if method not in ("continuous", "hill", "discrete", "auto"):
          raise ValueError("unknown method: %s" % method)
  
      force_continuous = method in ("continuous", "hill")
      return FittedPowerLaw(
          *_power_law_fit(data, xmin, force_continuous, p_precision)
      )
  
imports: import math
label_desc: Use image node_id 4 for calling a global function with example usage: power_law_fit(data, xmin, method, p_precision) and returns: FittedPowerLaw