Created
December 3, 2010 13:02
-
-
Save rodrigoflores/726925 to your computer and use it in GitHub Desktop.
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
1 3.0 | |
0.95 10.0 | |
0.90 15.0 | |
0.85 8.0 | |
0.80 7. | |
0.75 6.0 | |
0.70 5.0 | |
0.65 4.0 | |
0.50 3.0 | |
0.45 3.0 | |
0.4 3.0 |
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
#include<stdio.h> | |
#include<stdlib.h> | |
#include<math.h> | |
#include <time.h> | |
#define VMAX 1000 | |
#define NMAX 67.0 | |
int main() | |
{ | |
int j; | |
double average,stddev, S[VMAX], Freq[VMAX], Dist[VMAX]; | |
FILE *statdata, *data; | |
data=fopen("data.txt","r"); | |
statdata=fopen("stat-data.txt","w"); | |
while(fscanf(data,"%lf %lf", &S[j], &Freq[j]) > 0) { | |
// fscanf(data,"%lf", &Freq[j]); | |
Dist[j]=fabs(S[j]*Freq[j]-NMAX); | |
} | |
for(j=0, average=0.0;NMAX>j;j=j+1) | |
average=Dist[j]+average; | |
average=average/NMAX; | |
for(j=0, stddev=0.0;NMAX>j;j=j+1) | |
stddev=(average-Dist[j])*(average-Dist[j])+stddev; | |
stddev=stddev/NMAX; | |
stddev=sqrt(stddev); | |
if(average-(stddev*3)<0) | |
fprintf(statdata,"the sample is very bad, the average distance is %g and the standard deviation is %g",average, stddev); | |
else if(average-(stddev*3)>1) | |
fprintf(statdata,"the sample is very good, the average distance is %g and the standard deviation is %g",average, stddev); | |
else | |
fprintf(statdata,"the sample is ok, the average distance is %g and the standard deviation is %g. We recommend to add more data",average, stddev); | |
fclose(data); | |
fclose(statdata); | |
//system("PAUSE"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the sample is very bad, the average distance is 0.98209 and the standard deviation is 7.97853%