code: public double[] znorm(double[] series, double normalizationThreshold) {
      double[] res = new double[series.length];
      double sd = stDev(series);
      if (sd < normalizationThreshold) {
        // return series.clone();
        // return array of zeros
        return res;
      }
      double mean = mean(series);
      for (int i = 0; i < res.length; i++) {
        res[i] = (series[i] - mean) / sd;
      }
      return res;
    }
docs: Z-Normalize routine.
  
  @param series the input timeseries.
  @param normalizationThreshold the zNormalization threshold value.
  @return Z-normalized time-series.