code: private double calcMean(double[] arr) {
          double mean = 0;
          for (double resid : arr) {
              mean += resid;
          }
          mean /= arr.length;
          return mean;
      }
docs: Output: mean of array