Standard Deviation

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



									/*****Please include following header files*****/
// math.h
/***********************************************/

double StandardDeviation(double data[], int dataSize)
{
	double mean = 0.0;
	double sumDeviation = 0.0;

	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 sqrt(sumDeviation / dataSize);
}
								


Example

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


Output

									17.211623979160130