docs: public static double areaUnderCurve(XYCurve curve) {
      DoubleArray data = curve.data;
      double prevx = data.get(0), prevy = data.get(1);
      if (prevx > curve.minx) {
        throw new UnsupportedOperationException("Curves must be monotone on X for areaUnderCurve to be valid.");
      }
      double area = 0.0;
      for (int pos = 2; pos < data.size(); pos += 2) {
        final double curx = data.get(pos), cury = data.get(pos + 1);
        if (prevx > curx) {
          throw new UnsupportedOperationException("Curves must be monotone on X for areaUnderCurve to be valid.");
        }
        area += (curx - prevx) * (prevy + cury) * .5; // .5 = mean Y
        prevx = curx;
        prevy = cury;
      }
      if (prevx < curve.maxx) {
        throw new UnsupportedOperationException("Curves must be complete on X for areaUnderCurve to be valid.");
      }
      return area;
    }