code: public static double nashsut(double[] prediction, double[] validation, double pow) {
          int pre_size = prediction.length;
          int val_size = validation.length;
  
          int steps = 0;
  
          double sum_td = 0;
          double sum_vd = 0;
  
          /** checking if both data arrays have the same number of elements*/
          if (pre_size != val_size) {
              System.err.println("Prediction data and validation data are not consistent!");
              return -9999;
          } else {
              steps = pre_size;
          }
  
          /**summing up both data sets */
          for (int i = 0; i < steps; i++) {
              sum_td = sum_td + prediction[i];
              sum_vd = sum_vd + validation[i];
          }
  
          /** calculating mean values for both data sets */
          double mean_td = sum_td / steps;
          double mean_vd = sum_vd / steps;
  
          /** calculating mean pow deviations */
          double td_vd = 0;
          double vd_mean = 0;
          for (int i = 0; i < steps; i++) {
              td_vd = td_vd + (Math.pow((Math.abs(validation[i] - prediction[i])), pow));
              vd_mean = vd_mean + (Math.pow((Math.abs(validation[i] - mean_vd)), pow));
          }
          /** calculating efficiency after Nash & Sutcliffe (1970) */
          double efficiency = 1 - (td_vd / vd_mean);
          return efficiency;
      }
docs: Calculates the efficiency between a test data set and a verification data set
  after Nash & Sutcliffe (1970). The efficiency is described as the proportion of
  the cumulated cubic deviation between both data sets and the cumulated cubic
  deviation between the verification data set and its mean value.
  @param prediction the simulation data set
  @param validation the validation (observed) data set
  @param pow the power for the deviation terms
  @return the calculated efficiency or -9999 if an error occurs