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 ; }
Calculate the standard deviation from an amount of values n a sum and a sum of squares .