public void addOutliers ( List < Point2D3D > observations , int total ) { int size = observations . size ( ) ; for ( int i = 0 ; i < total ; i ++ ) { // outliers will be created by adding lots of noise to real observations Point2D3D p = observations . get ( rand . nextInt ( size ) ) ; Point2D3D o = new Point2D3D ( ) ; o . observation . set ( p . observation ) ; o . location . x = p . location . x + rand . nextGaussian ( ) * 5 ; o . location . y = p . location . y + rand . nextGaussian ( ) * 5 ; o . location . z = p . location . z + rand . nextGaussian ( ) * 5 ; observations . add ( o ) ; } // randomize the order Collections . shuffle ( observations , rand ) ; }
Adds some really bad observations to the mix