Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
ibinom.c
Go to the documentation of this file.00001 #include "mrilib.h"
00002
00003 int main( int argc , char * argv[] )
00004 {
00005 double qq , nn , pp , tt ;
00006
00007 if( argc < 4 || strcmp(argv[1],"-help")==0 ){
00008 printf("Usage: ibinom Q N p\n"
00009 " Q = upper tail probability\n"
00010 " N = number of trials\n"
00011 " p = probability of success per trial\n"
00012 "Output is value 'm' such that the binomial probability\n"
00013 "of getting m or more successes in N trials is Q.\n"
00014 ) ;
00015 exit(0) ;
00016 }
00017
00018 qq = strtod( argv[1] , NULL ) ;
00019 nn = strtod( argv[2] , NULL ) ;
00020 pp = strtod( argv[3] , NULL ) ;
00021
00022 #define BAD(str) ( fprintf(stderr,"Bad value of %s\n",str) , exit(1) )
00023
00024 if( qq <= 0.0 || qq >= 1.0 ) BAD("Q") ;
00025 if( nn <= 1.0 ) BAD("N") ;
00026 if( pp <= 0.0 || pp >= 1.0 ) BAD("p") ;
00027
00028 tt = binomial_p2t( qq , nn , pp ) ;
00029 printf("threshold = %g\n",tt) ;
00030 exit(0) ;
00031 }