code: public static int argMin(final double[] x) {
      checkArgument(x.length > 0);
      double minValue = Double.MAX_VALUE;
      int minIndex = 0;
  
      for (int i = 0; i < x.length; ++i) {
        final double val = x[i];
        if (val < minValue) {
          minIndex = i;
          minValue = val;
        }
      }
      return minIndex;
    }
docs: Returns the index of the first minimal element of the array. That is, if there is a unique
  minimum, its index is returned. If there are multiple values tied for smallest, the index of
  the first is returned. If the supplied array is empty, an {@link IllegalArgumentException} is
  thrown.