code: public static double stdDeviation(final long n, final double sum, final double sumOfSquares) {
      double stdDev = 0;
      if (n > 1) { // std deviation for 1 entry is 0 by definition
  
        final double numerator = sumOfSquares - ((sum * sum) / n);
        stdDev = java.lang.Math.sqrt(numerator / (n - 1));
      }
      return stdDev;
    }
docs: Calculate the standard deviation from an amount of values n, a sum and a sum of squares.
  
  @param n the number of values measured.
  @param sum the total sum of values measured.
  @param sumOfSquares the total sum of squares of the values measured.
  @return the standard deviation of a number of values.