code: public double stDev(double[] series) {
      double num0 = 0D;
      double sum = 0D;
      int count = 0;
      for (double tp : series) {
        num0 = num0 + tp * tp;
        sum = sum + tp;
        count += 1;
      }
      double len = ((Integer) count).doubleValue();
      return Math.sqrt((len * num0 - sum * sum) / (len * (len - 1)));
    }
docs: Speed-optimized implementation.
  
  @param series The timeseries.
  @return the standard deviation.