code: private static double[][] quantile(double[] x, double[] y) {
          Arrays.sort(x);
          Arrays.sort(y);
  
          int n = Math.min(x.length, y.length);
  
          double[][] q = new double[n][2];
          for (int i = 0; i < n; i++) {
              double p = (i + 1) / (n + 1.0);
              q[i][0] = x[(int) Math.round(p * x.length)];
              q[i][1] = y[(int) Math.round(p * y.length)];
          }
  
          return q;
      }
docs: Generate the quantile-quantile pairs.