code: public static double median (double[] vector) {
          final double[] sorted = vector.clone();
          Arrays.sort(sorted);
          if (vector.length % 2 == 1) {
              return sorted[vector.length / 2];
          }
          return (sorted[vector.length / 2 - 1] + sorted[vector.length / 2]) / 2;
      }
docs: Returns the median of the vector.
  
  @param vector The input vector as a double array
  @return The median of the vector