docs: public double getMedianValue() {
          Lock lock = this.getLock().writeLock();
          try {
              lock.lock();
              int count = this.values.size();
              if (count == 0) {
                  return 0.0d;
              }
              if (this.medianValue == null) {
                  // Sort the values in numerical order..
                  Comparator<T> comparator = this.math.getComparator();
                  Collections.sort(this.values, comparator);
                  this.medianValue = 0.0d;
                  // If there is only one value, then the median is that value ...
                  if (count == 1) {
                      this.medianValue = this.values.get(0).doubleValue();
                  }
                  // If there is an odd number of values, find value that is in the middle ..
                  else if (count % 2 != 0) {
                      this.medianValue = this.values.get(((count + 1) / 2) - 1).doubleValue();
                  }
                  // Otherwise, there is an even number of values, so find the average of the middle two values ...
                  else {
                      int upperMiddleValueIndex = count / 2;
                      int lowerMiddleValueIndex = upperMiddleValueIndex - 1;
                      double lowerValue = this.values.get(lowerMiddleValueIndex).doubleValue();
                      double upperValue = this.values.get(upperMiddleValueIndex).doubleValue();
                      this.medianValue = (lowerValue + upperValue) / 2.0d;
                  }
                  this.median = this.math.create(this.medianValue);
                  this.histogram = null;
              }
          } finally {
              lock.unlock();
          }
          return this.medianValue;
      }