@Override public double[][] processQueryResults(DoubleDBIDList results,Relation<? extends NumberVector> database,int k){
  final int dim=RelationUtil.dimensionality(database);
  final CovarianceMatrix cmat=new CovarianceMatrix(dim);
  if (k > results.size()) {
    k=results.size();
  }
  double maxdist=0.0;
  double 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=Math.sqrt(stddev / k);
  }
  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.destroyToNaiveMatrix();
}

@ Override public double [ ] [ ] processQueryResults ( DoubleDBIDList results , Relation < ? extends NumberVector > database , int k ) { final int dim = RelationUtil . dimensionality ( database ) ; final CovarianceMatrix cmat = new CovarianceMatrix ( dim ) ; if ( k > results . size ( ) ) { k = results . size ( ) ; } double maxdist = 0.0 ; double 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 = Math . sqrt ( stddev / k ) ; } 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 . destroyToNaiveMatrix ( ) ; }
compute covariance matrix for a queryresult collection . by default it will just collect the ids and run processids
