Standard Deviation

This algorithm calculates the standard deviation of the given set of numbers.



									public static double StandardDeviation(double[] data)
{
	double mean = 0.0;
	double sumDeviation = 0.0;
	int dataSize = data.Length;

	for (int i = 0; i < dataSize; ++i)
		mean += data[i];

	mean = mean / dataSize;

	for (int i = 0; i < dataSize; ++i)
		sumDeviation += (data[i] - mean) * (data[i] - mean);

	return Math.Sqrt(sumDeviation / dataSize);
}
								


Example

									double[] data = { 13, 23, 12, 44, 55 };
double standardDeviation = StandardDeviation(data);
								


Output

									17.21162397916013