code: public static List<Pair> toPairs(List<Double> xyValues, double missingValue) {
          List<Pair> result = new ArrayList<Pair>((xyValues.size() + 1) / 2);
          Iterator<Double> it = xyValues.iterator();
          while (it.hasNext()) {
              result.add(new Pair(it.next(), it.hasNext() ? it.next() : missingValue));
          }
          return result;
      }
docs: Creates a list of Pair from a list of scalars given in the form
  
  `(x_1,y_1,...,x_n,y_n)`
  
  @param xyValues is a list of scalars given as
  `(x_1,y_1,...,x_n,y_n)` possibly missing a value
  @param missingValue is the replacement in the case a value is missing from
  `xy`
  @return a vector of Pair in the form
  `\left(\{x_1,y_1\},...,\{x_n,y_n\}\right)`