public final double getMedian ( ) { assertNotEmpty ( ) ; // Sort the data (take a copy to do this). double [ ] dataCopy = new double [ getSize ( ) ] ; System . arraycopy ( dataSet , 0 , dataCopy , 0 , dataCopy . length ) ; Arrays . sort ( dataCopy ) ; int midPoint = dataCopy . length / 2 ; if ( dataCopy . length % 2 != 0 ) { return dataCopy [ midPoint ] ; } else { return dataCopy [ midPoint - 1 ] + ( dataCopy [ midPoint ] - dataCopy [ midPoint - 1 ] ) / 2 ; } }
Determines the median value of the data set .