docs: public static DoubleIntPair bestChangeInMean(double[] sums, int begin, int end) {
      final int len = end - begin, last = end - 1;
      final double suml = begin > 0 ? sums[begin - 1] : 0.;
      final double sumr = sums[last];
  
      int bestpos = begin;
      double bestscore = Double.NEGATIVE_INFINITY;
      // Iterate elements k=2..n-1 in math notation_
      for(int j = begin, km1 = 1; j < last; j++, km1++) {
        assert (km1 < len); // FIXME: remove eventually
        final double sumj = sums[j]; // Sum _inclusive_ j'th element.
        // Derive the left mean and right mean from the precomputed aggregates:
        final double lmean = (sumj - suml) / km1;
        final double rmean = (sumr - sumj) / (len - km1);
        // Equation 2.6.17 from the Basseville book
        final double dm = lmean - rmean;
        final double score = km1 * (double) (len - km1) * dm * dm;
        if(score > bestscore) {
          bestpos = j + 1;
          bestscore = score;
        }
      }
      return new DoubleIntPair(bestscore, bestpos);
    }