32 #include <bias_config.h>
34 #include <Base/Debug/Debug.hh>
35 #include <Base/Debug/Error.hh>
37 #include <Base/Common/BIASpragma.hh>
43 int main(
int argc,
char *argv[])
46 cerr <<
"Not enough parameters given!" << endl;
47 cout <<
"Usage: ExampleMeanAndDev [file name] [columns]" << endl;
50 FILE* myfile = fopen(argv[1],
"r");
51 const int column = atoi(argv[2]);
53 int nummeasurements = 0;
54 float *value =
new float[column];
55 double valuesum=0,mean=0;
57 while (fgets(thestring, 1020, myfile)) {
58 if (sscanf(thestring,
"%f %f %f",&(value[0]),&(value[1]),&(value[2])) <
61 valuesum += value[column-1];
64 mean = valuesum / double(nummeasurements);
66 myfile = fopen(argv[1],
"r");
70 while (fgets(thestring, 1020, myfile)) {
71 if (sscanf(thestring,
"%f %f %f",&(value[0]),&(value[1]),&(value[2])) <
74 valuesum += (mean-value[column-1]) * (mean-value[column-1]);
76 valuesum /= double(nummeasurements-1);
77 cout<<
"Mean is "<< mean <<
" and dev is "<<sqrt(valuesum)<<
" on "
78 <<nummeasurements<<
" measurements"<<endl;