1 #ifdef HAVE_CONFIG_H
2 #include "../config.h"
3 #endif /* HAVE_CONFIG_H */
4
5 #ifndef DO_WITH_GSL
6
7 /* This test is not performed */
main()8 int main()
9 {
10 return 0;
11 }
12
13 #else
14
15 #include <stdio.h>
16 #include <gsl/gsl_rng.h>
17 #include <gsl/gsl_randist.h>
18 #include <gsl/gsl_histogram.h>
19
20
main(void)21 int main(void)
22 {
23 FILE* out_file; /* output stream*/
24 int i;
25 double cut_off;
26 double sigma;
27 const int sample_no=100000; /* sample numbers */
28 const int bin_no=100; /* number of bins in histogram */
29 gsl_histogram* my_hist;
30 gsl_rng* my_rng;
31
32 out_file=stdout;
33 my_hist=gsl_histogram_calloc_uniform(bin_no,-10,10);
34 my_rng=gsl_rng_alloc(gsl_rng_default);
35
36 sigma=1;
37 cut_off=-4;
38
39 fprintf(out_file,"plot '-' using 1:3 title '1st',");
40 fprintf(out_file,"'-' using 1:3 title '2nd',");
41 fprintf(out_file,"'-' using 1:3 title '3rd'\n");
42 while (cut_off<=4)
43 {
44 fprintf(out_file,"# cut_off %f, sigma %f\n",cut_off,sigma);
45 gsl_histogram_reset(my_hist);
46 for (i=0;i<sample_no;i++)
47 gsl_histogram_increment(my_hist,gsl_ran_gaussian_tail(my_rng,cut_off,sigma));
48 gsl_histogram_fprintf(out_file,my_hist,"%f","%f");
49 fprintf(out_file,"e\n");
50 cut_off+=4;
51 }
52 return 0;
53 }
54
55 #endif
56