Thursday, July 30, 2009

C program for calculating variance?

i require a c program to calculate the variance for set of 24000 values.

C program for calculating variance?
Wikipedia is your Friend !





Compute the mean;


subtract the mean from each number (the outcomes are called "deviations");


square the deviations;


take the mean of these squares.





OR





n = 0


mean = 0


S = 0





foreach x in data:


n = n + 1


delta = x - mean


mean = mean + delta/n


S = S + delta*(x - mean)


end for





variance = S/(n - 1)


No comments:

Post a Comment