// preprocess kNN neighborhoods
assert (k == this.k);
KNNQuery<V, DoubleDistance> knnQuery = QueryUtil.getKNNQuery(relation, getDistanceFunction(), k);
for(DBID objKey : relation.iterDBIDs()) {
MeanVariance s = new MeanVariance();
// System.out.println("Processing: " +objKey);
KNNResult<DoubleDistance> neighbors = knnQuery.getKNNForDBID(objKey, k);
Iterator<DistanceResultPair<DoubleDistance>> iter = neighbors.iterator();
while(iter.hasNext()) {
DBID key1 = iter.next().getDBID();
// Iterator iter2 = data.keyIterator();
Iterator<DistanceResultPair<DoubleDistance>> iter2 = neighbors.iterator();
// PriorityQueue best = new PriorityQueue(false, k);
while(iter2.hasNext()) {
DBID key2 = iter2.next().getDBID();
if(key2.equals(key1) || key1.equals(objKey) || key2.equals(objKey)) {
continue;
}
double nenner = calcDenominator(kernelMatrix, objKey, key1, key2);
if(nenner != 0) {
double sqrtnenner = Math.sqrt(nenner);
double tmp = calcNumerator(kernelMatrix, objKey, key1, key2) / nenner;
s.put(tmp, 1 / sqrtnenner);
}
}
}
// Sample variance probably would be correct, however the numerical
// instabilities can actually break ABOD here.
pq.add(new DoubleObjPair<DBID>(s.getNaiveVariance(), objKey));
}
DoubleMinMax minmaxabod = new DoubleMinMax();
WritableDoubleDataStore abodvalues = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC);
for(DoubleObjPair<DBID> pair : pq) {