code: @Override
      public double defuzzify(Term term, double minimum, double maximum) {
          if (!Op.isFinite(minimum + maximum)) {
              return Double.NaN;
          }
  
          final int resolution = getResolution();
          final double dx = (maximum - minimum) / resolution;
          double x, y;
          double ymax = -1.0;
          double xsmallest = minimum;
          double xlargest = maximum;
          boolean samePlateau = false;
          for (int i = 0; i < resolution; ++i) {
              x = minimum + (i + 0.5) * dx;
              y = term.membership(x);
  
              if (Op.isGt(y, ymax)) {
                  ymax = y;
  
                  xsmallest = x;
                  xlargest = x;
  
                  samePlateau = true;
              } else if (samePlateau && Op.isEq(y, ymax)) {
                  xlargest = x;
              } else if (Op.isLt(y, ymax)) {
                  samePlateau = false;
              }
          }
  
          return (xlargest + xsmallest) / 2.0;
      }
docs: Computes the mean value of the maximum membership function of a fuzzy set.
  The mean value is computed while integrating over the fuzzy set. The
  integration algorithm is the midpoint rectangle method
  (https://en.wikipedia.org/wiki/Rectangle_method).
  
  @param term is the fuzzy set
  @param minimum is the minimum value of the fuzzy set
  @param maximum is the maximum value of the fuzzy set
  @return the mean `x`-coordinate of the maximum membership function
  value in the fuzzy set