/* this program calculates the a, b, c, d values and FDR, FNR, FNDR, and FPR */ /* just take the lines below the "Observations" line in the EMMIX output and use it as input here */ #include #include #include main(int argc, char **argv) { double t0[25000], t1[25000]; FILE *f; double a,b,c,d; double fpr[100],fnr[100],fdr[100],fndr[100],sens[100],spec[100]; int i,n,c0; if (argc!=3) { printf("usage: %s filename rows\n",argv[0]);exit(0);} n = atoi(argv[2]); f = fopen(argv[1],"r"); if (!f) {printf("error opening %s\n",argv[1]); exit(0);} for (i = 0; i < n; i++) { int l; double dummy; fscanf(f,"%d %lf %lf",&l,&dummy,&t0[i]); fscanf(f,"%lf",&t1[i]); } fclose(f); for (c0 = 10; c0 <= 50; c0 += 10) { a = b = c = d = 0; for (i = 0; i < n; i++) { int z0,z1; if (t0[i] < c0/100.0) z0 = 0; else z0 = 1; z1 = 1 - z0; a += t0[i] * z0; b += t0[i] * z1; c += t1[i] * z0; d += t1[i] * z1; } printf("c0=%lf a=%lf b=%lf c=%lf d=%lf b+d=%lf\n",c0/100.0,a,b,c,d,b+d); /*printf("fdr=%lf\n",b/(a+b)); printf("fnr=%lf\n",c/(c+d)); printf("fdr=%lf\n",b/(b+d)); printf("fndr=%lf\n",c/(a+c)); printf("sensitivity=%lf\n",d/(d+c)); printf("specificity=%lf\n",a/(a+b)); printf("----------------------------------------\n"); */ fpr[c0] = b/(a+b); fnr[c0] = c/(c+d); fdr[c0] = b/(b+d); fndr[c0] = c/(a+c); sens[c0] = d/(c+d); spec[c0] = a/(a+b); } printf("c0 fdr fndr fnr fpr\n"); for (c0 = 10; c0 <= 50; c0 += 10) { printf("%0.5f %0.5f %0.5f %0.5f %0.5f \n", c0/100.0,fdr[c0],fndr[c0],fnr[c0],fpr[c0]); } }