I haven't really used variance calculation that much, and I don't know quite what to expect. Actually I'm not too good with math at all.
I have a an array of 1000000 random numeric values in the range 0-10000.
The array could grow even larger, so I use 64 bit int for sum.
I have tried to find code on how to calc variance, but I don't know if I get correct output.
The mean is 4692 and median is 4533. I get variance 1483780.469308 using the following code:
// size is the element count, in this case 1000000
// value_sum is __int64
double p2 = pow( (double)(value_sum - (value_sum/size)), (double)2.0 );
double variance = sqrt( (double)(p2 / (size-1)) );
Am I getting a reasonable value?
Is anything wrong with the calculation?