code: 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;
          }
      }
docs: Determines the median value of the data set.
  @return If the number of elements is odd, returns the middle element.
  If the number of elements is even, returns the midpoint of the two
  middle elements.
  @since 1.0.1