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 area = 0;
          double xcentroid = 0;
  
          //double ycentroid = 0;
          for (int i = 0; i < resolution; ++i) {
              x = minimum + (i + 0.5) * dx;
              y = term.membership(x);
  
              xcentroid += y * x;
              //ycentroid += y * y;
              area += y;
          }
          //Final results not computed for efficiency
          //xcentroid /= area;
          //ycentroid /= 2 * area;
          //area *= dx;
          return xcentroid / area;
      }
docs: Computes the centroid of a fuzzy set. The defuzzification process
  integrates over the fuzzy set utilizing the boundaries given as parameters.
  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 `x`-coordinate of the centroid of the fuzzy set