@SuppressWarnings("unchecked") private static OutlierResult runOnlineLOF(UpdatableDatabase db){
  Relation<DoubleVector> rep=db.getRelation(TypeUtil.DOUBLE_VECTOR_FIELD);
  OnlineLOF<DoubleVector> lof=new OnlineLOF<>(k,k,neighborhoodDistanceFunction,reachabilityDistanceFunction);
  OutlierResult result=lof.run(db);
  ArrayList<DoubleVector> insertions=new ArrayList<>();
  NumberVector.Factory<DoubleVector> o=RelationUtil.getNumberVectorFactory(rep);
  int dim=RelationUtil.dimensionality(rep);
  Random random=new Random(seed);
  for (int i=0; i < size; i++) {
    DoubleVector obj=VectorUtil.randomVector(o,dim,random);
    insertions.add(obj);
  }
  DBIDs deletions=db.insert(MultipleObjectsBundle.makeSimple(rep.getDataTypeInformation(),insertions));
  db.delete(deletions);
  return result;
}

@ SuppressWarnings ( "unchecked" ) private static OutlierResult runOnlineLOF ( UpdatableDatabase db ) { Relation < DoubleVector > rep = db . getRelation ( TypeUtil . DOUBLE_VECTOR_FIELD ) ; OnlineLOF < DoubleVector > lof = new OnlineLOF < > ( k , k , neighborhoodDistanceFunction , reachabilityDistanceFunction ) ; OutlierResult result = lof . run ( db ) ; ArrayList < DoubleVector > insertions = new ArrayList < > ( ) ; NumberVector . Factory < DoubleVector > o = RelationUtil . getNumberVectorFactory ( rep ) ; int dim = RelationUtil . dimensionality ( rep ) ; Random random = new Random ( seed ) ; for ( int i = 0 ; i < size ; i ++ ) { DoubleVector obj = VectorUtil . randomVector ( o , dim , random ) ; insertions . add ( obj ) ; } DBIDs deletions = db . insert ( MultipleObjectsBundle . makeSimple ( rep . getDataTypeInformation ( ) , insertions ) ) ; db . delete ( deletions ) ; return result ; }
run onlinelof ( with insertions and removals ) on database .
