private void computeCOFScores ( KNNQuery < O > knnq , DBIDs ids , DoubleDataStore acds , WritableDoubleDataStore cofs , DoubleMinMax cofminmax ) { FiniteProgress progressCOFs = LOG . isVerbose ( ) ? new FiniteProgress ( "COF for objects" , ids . size ( ) , LOG ) : null ; for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { final KNNList neighbors = knnq . getKNNForDBID ( iter , k ) ; // Aggregate the average chaining distances of all neighbors: double sum = 0. ; for ( DBIDIter neighbor = neighbors . iter ( ) ; neighbor . valid ( ) ; neighbor . advance ( ) ) { // skip the point itself if ( DBIDUtil . equal ( neighbor , iter ) ) { continue ; } sum += acds . doubleValue ( neighbor ) ; } final double cof = ( sum > 0. ) ? ( acds . doubleValue ( iter ) * k / sum ) : ( acds . doubleValue ( iter ) > 0. ? Double . POSITIVE_INFINITY : 1. ) ; cofs . putDouble ( iter , cof ) ; // update minimum and maximum cofminmax . put ( cof ) ; LOG . incrementProcessed ( progressCOFs ) ; } LOG . ensureCompleted ( progressCOFs ) ; }
Compute Connectivity outlier factors .