protected double computeLOFScore ( KNNQuery < O > knnq , DBIDRef cur , DoubleDataStore lrds ) { final double lrdp = lrds . doubleValue ( cur ) ; if ( Double . isInfinite ( lrdp ) ) { return 1.0 ; } double sum = 0. ; int count = 0 ; final KNNList neighbors = knnq . getKNNForDBID ( cur , k ) ; for ( DBIDIter neighbor = neighbors . iter ( ) ; neighbor . valid ( ) ; neighbor . advance ( ) ) { // skip the point itself if ( DBIDUtil . equal ( cur , neighbor ) ) { continue ; } sum += lrds . doubleValue ( neighbor ) ; ++ count ; } return sum / ( lrdp * count ) ; }
Compute a single LOF score .