code: public void graphPrecisionRecall(PrintStream out) throws IOException 
      {
          /** find interpolated precision - max precision at any rank point after i */
          double[] interpolatedPrecision = new double[pairs.length];
          double n = numCorrectPairs;
          double maxPrecision = n/pairs.length;
          for (int i=pairs.length-1; i>=0; i--) {
              if (correctPair(i)) {
                  interpolatedPrecision[i] = maxPrecision;
                  n--;
                  maxPrecision = Math.max(maxPrecision, n/(i+1));
              }
          }
          /** plot points on the graph */
          n = 0;
          for (int i=0; i<pairs.length; i++) {
              if (correctPair(i)) {
                  n++;
                  double recallAtRankI = n/numCorrectPairs;
                  out.println(recallAtRankI+"\t"+interpolatedPrecision[i]);
              }
          }
      }
docs: Graph interpolated precision vs recall