docs: private PolynomialApproximation approximateKnnDistances(double[] knnDistances) {
      StringBuilder msg = new StringBuilder();
  
      // count the zero distances (necessary of log-log space is used)
      int k_0 = 0;
      if(settings.log) {
        for(int i = 0; i < settings.kmax; i++) {
          double dist = knnDistances[i];
          if(dist == 0) {
            k_0++;
          }
          else {
            break;
          }
        }
      }
  
      double[] x = new double[settings.kmax - k_0];
      double[] y = new double[settings.kmax - k_0];
  
      for(int k = 0; k < settings.kmax - k_0; k++) {
        if(settings.log) {
          x[k] = FastMath.log(k + k_0);
          y[k] = FastMath.log(knnDistances[k + k_0]);
        }
        else {
          x[k] = k + k_0;
          y[k] = knnDistances[k + k_0];
        }
      }
  
      PolynomialRegression regression = new PolynomialRegression(y, x, settings.p);
      PolynomialApproximation approximation = new PolynomialApproximation(regression.getEstimatedCoefficients());
  
      if(LOG.isDebugging()) {
        msg.append("approximation ").append(approximation);
        LOG.debugFine(msg.toString());
      }
      return approximation;
  
    }