code: public double mean(double[] series) {
      double res = 0D;
      int count = 0;
      for (double tp : series) {
        res += tp;
        count += 1;
  
      }
      if (count > 0) {
        return res / ((Integer) count).doubleValue();
      }
      return Double.NaN;
    }
docs: Computes the mean value of timeseries.
  
  @param series The timeseries.
  @return The mean value.