code: private static double[] toArray(List<Double> list) {
      double[] values = new double[list.size()];
      for (int i = 0; i < values.length; i++) {
        values[i] = list.get(i);
      }
      return values;
    }
docs: Method for turning a list of doubles to an array.
  
  @param list List of doubles
  @return Array of doubles.