code: private int computePk2Measure(double[] objectiveScores) {
          LOGGER.fine("Computing the PK2 measure");
  
          // Compute each Pk2 score and the average score.
          double average = 0;
          for (int k = objectiveScores.length - 1; k > 0; --k) {
              objectiveScores[k] /= objectiveScores[k-1];
              average += objectiveScores[k];
          }
          average /= (objectiveScores.length - 1);
  
          // Compute the standard deviation of the PK2 scores.
          double stdev = 0;
          for (int k = 1; k < objectiveScores.length; ++k)
              stdev += Math.pow(objectiveScores[k] - average, 2);
          stdev /= (objectiveScores.length - 2);
          stdev = Math.sqrt(stdev);
  
          // Find the point where the score is the smallest value greater than 1 +
          // stdev of the PK1 scores.
          double referencePoint = 1 + stdev;
          int bestIndex = 0;
          double bestScore = Double.MAX_VALUE;
          for (int k = 1; k < objectiveScores.length; ++k) {
              if (objectiveScores[k] < bestScore &&
                  objectiveScores[k] >= referencePoint) {
                  bestIndex = k;
                  bestScore = objectiveScores[k];
              }
          }
  
          return bestIndex;
      }
docs: Compute the smallest k that satisfies the Pk3 method.