code: public static INDArray movingAverage(INDArray toAvg, int n) {
          INDArray ret = Nd4j.cumsum(toAvg);
          INDArrayIndex[] ends = new INDArrayIndex[] {NDArrayIndex.interval(n, toAvg.columns())};
          INDArrayIndex[] begins = new INDArrayIndex[] {NDArrayIndex.interval(0, toAvg.columns() - n, false)};
          INDArrayIndex[] nMinusOne = new INDArrayIndex[] {NDArrayIndex.interval(n - 1, toAvg.columns())};
          ret.put(ends, ret.get(ends).sub(ret.get(begins)));
          return ret.get(nMinusOne).divi(n);
      }
docs: Calculate a moving average given the length
  @param toAvg the array to average
  @param n the length of the moving window
  @return the moving averages for each row