code: public static double mean(double[] a) {
  
          if (a.length == 0) return Double.NaN;
          double sum = sum(a);
          return sum / a.length;
      }
docs: Returns the average value in the specified array.
  
  @param  a the array
  @return the average value in the array {@code a[]};
  {@code Double.NaN} if no such value