/****************************************************************/ /*** Generator for exponentially distributed numbers ***/ /*** Rechnergestütztes Wissenschaftliches Rechnen ***/ /*** University of Goettingen, Germany 2004 ***/ /****************************************************************/ #include #include #include #define NUM_BINS 100 int main(int argc, char *argv[]) { int histo[NUM_BINS]; /* histogram */ int bin; double start_histo, end_histo; /* range of histogram */ double delta; /* width of bin */ int t; /* loop counter */ int num_runs; /* number of generated random numbers */ double lambda; /* parameter of distribution */ double number; /* generated number */ num_runs = atoi(argv[1]); /* read parameters */ sscanf(argv[2], "%lf", &lambda); for(t=0; t= 0)&&(bin < NUM_BINS)) /* inside range ? */ histo[bin]++; /* count event */ } for(t=0; t