code: public static double avg( List<SimpleFeature> features, String field ) {
          double sum = 0;
          int count = 0;
          for( SimpleFeature feature : features ) {
              Object attribute = feature.getAttribute(field);
              if (attribute instanceof Number) {
                  sum = sum + ((Number) attribute).doubleValue();
                  count++;
              }
          }
          double avg = sum / count;
          return avg;
      }
docs: Calculate the avg of a value in a list of {@link SimpleFeature}s.
  
  <p>Empty records are ignored.
  
  @param features the features.
  @param field the field to consider.
  @return the avg.