docs: @Override
    public double[][] processQueryResults(DoubleDBIDList results, Relation<? extends NumberVector> database, int k) {
      final int dim = RelationUtil.dimensionality(database);
      final CovarianceMatrix cmat = new CovarianceMatrix(dim);
  
      // avoid bad parameters
      k = k <= results.size() ? k : results.size();
  
      // find maximum distance
      double maxdist = 0.0, stddev = 0.0;
      {
        int i = 0;
        for(DoubleDBIDListIter it = results.iter(); it.valid() && i < k; it.advance(), k++) {
          final double dist = it.doubleValue();
          stddev += dist * dist;
          if(dist > maxdist) {
            maxdist = dist;
          }
        }
        if(maxdist == 0.0) {
          maxdist = 1.0;
        }
        stddev = FastMath.sqrt(stddev / k);
      }
  
      // calculate weighted PCA
      int i = 0;
      for(DoubleDBIDListIter it = results.iter(); it.valid() && i < k; it.advance(), k++) {
        final double dist = it.doubleValue();
        NumberVector obj = database.get(it);
        double weight = weightfunction.getWeight(dist, maxdist, stddev);
        cmat.put(obj, weight);
      }
      return cmat.destroyToPopulationMatrix();
    }