Skip to content

Instantly share code, notes, and snippets.

@snadahalli

snadahalli/stddev.c

Created Dec 3, 2013
Embed
What would you like to do?
Function to calculate standard deviation.
float computeStandardDeviation(float a[], int n, float mean) {
float variance, deviation, sumsquare = 0;
int i;
for(i=0; i<n; i++) {
deviation = a[i] - mean;
sumsquare += deviation * deviation;
}
variance = sunsquare/(float)n;
return sqrt(variance);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment