public static double meanCenter ( DenseMatrix64F points , DenseMatrix64F center ) { assert points . numCols == 2 ; assert center . numCols == 1 ; assert center . numRows == 2 ; center . zero ( ) ; int count = points . numRows ; double [ ] d = points . data ; for ( int i = 0 ; i < count ; i ++ ) { center . add ( 0 , 0 , d [ 2 * i ] ) ; center . add ( 1 , 0 , d [ 2 * i + 1 ] ) ; } if ( count > 0 ) { divide ( center , count ) ; DenseMatrix64F di = new DenseMatrix64F ( points . numRows , 1 ) ; computeDi ( center , points , di ) ; return elementSum ( di ) / ( double ) points . numRows ; } else { return Double . NaN ; } }
Calculates mean tempCenter of points