2 /* copyright (c) 1996, 1997, 1998, 1999 William R. Pearson and the
5 /* $Name: fa_34_26_5 $ - $Id: sc_to_e.c,v 1.2 2006/04/12 18:00:02 wrp Exp $ */
7 /* sc_to_e uses statistical parameters from search and
8 score, length, and database size to calculate E()
15 double mean_var, mu, rho;
18 int argc; char **argv;
21 int score, length, db_size;
22 double z_val, s_to_zv(), zv_to_E();
25 sscanf(argv[1],"%lf",&rho);
26 sscanf(argv[2],"%lf",&mu);
27 sscanf(argv[3],"%lf",&mean_var);
30 fprintf(stderr," enter rho mu mean_var: ");
31 fgets(line,sizeof(line),stdin);
32 sscanf(line,"%lf %lf %lf",&rho, &mu, &mean_var);
36 fprintf(stderr," enter score length db_size: ");
37 if (fgets(line,sizeof(line),stdin)==NULL) exit(0);
38 if (line[0]=='\n') exit(0);
39 sscanf(line,"%d %d %d",&score, &length, &db_size);
40 if (db_size < 1) db_size = 50000;
42 z_val = s_to_zv(score, length);
44 printf(" s: %d (%d) E(%d): %4.2g\n",score,length,db_size,zv_to_E(z_val,db_size));
48 double s_to_zv(int score, int length)
50 return ((double)score - rho * log((double)length) - mu)/sqrt(mean_var);
53 double zv_to_E(double zv, int db_size)
57 e = exp(-1.282554983 * zv - .577216);
58 return (double)db_size * (e > .01 ? 1.0 - exp(-e) : e);