code: private int getMax(double data[]) {
          int idx = 0;
          double max = data[0];
          for (int i = 1; i < data.length; i++) {
              if (max < data[i]) {
                  max = data[i];
                  idx = i;
              }
          }
          return idx;
      }
docs: Searches maximum value in the specified array.
  
  @param data input data.
  @return the index of the maximum value in the data array.