code: public static double average(List<? extends Number> values) {
          if (values == null || values.isEmpty()) return 0D;
  
          double sum = 0D;
          for (Number v : values) sum += v.doubleValue();
  
          return sum / values.size();
      }
docs: Computes the average/mean/expected value of a list of numbers.
  @param values    list of values
  @return the computed average