code: public static int argMax(final double[] x, final int startInclusive, final int endExclusive) {
      checkArgument(endExclusive > startInclusive);
      checkArgument(startInclusive >= 0);
      checkArgument(endExclusive <= x.length);
  
      double maxValue = Double.MIN_VALUE;
      int maxIndex = 0;
  
      for (int i = startInclusive; i < endExclusive; ++i) {
        final double val = x[i];
        if (val > maxValue) {
          maxIndex = i;
          maxValue = val;
        }
      }
      return maxIndex;
    }
docs: Returns the index of the first maximal element of the array within the specified bounds. That
  is, if there is a unique maximum, its index is returned. If there are multiple values tied for
  largest, the index of the first is returned. If the supplied array is empty, an {@link
  IllegalArgumentException} is thrown.