Created
December 20, 2011 16:01
-
-
Save musically-ut/1502070 to your computer and use it in GitHub Desktop.
Testing Standard Deviation calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
StdDevCalc c, c2; | |
StdDevCalcKnuth k, k2; | |
for(int i = 0; i < 100; i++) { | |
c.append(i); // Small values | |
k.append(i); | |
c2.append((double) i * 3e151); // Very very large values | |
k2.append((double) i * 3e151); | |
} | |
cout << c.get_std_dev() << endl; // 29.0115 | |
cout << k.get_std_dev() << endl; // 29.0115 | |
cout << endl; | |
cout << c2.get_std_dev() << endl; // inf | |
cout << k2.get_std_dev() << endl; // 8.70345e+152 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment