public static double StandardDeviation(IEnumerable‹double› sequence)
{
(int count, double sum, double sumOfSquares) = ComputeSumAndSumOfSquares(sequence);
var variance = sumOfSquares - sum * sum / count;
return Math.Sqrt(variance / count);
}