00001
00013
00014 #include <stdlib.h>
00015 #include <stdio.h>
00016 #include <string.h>
00017 #include <strings.h>
00018 #include <limits.h>
00019 #include <math.h>
00020 #include <time.h>
00021 #include <gsl/gsl_errno.h>
00022 #include <gsl/gsl_randist.h>
00023 #include <gsl/gsl_rng.h>
00024
00025
00026
00027
00028 #define AREA_1 12.0
00029 #define CNTR_1 20.5
00030 #define WDTH_1 8.0
00031 #define SHPE_1 1.0
00032
00033 #define AREA_2 -12.0
00034 #define CNTR_2 70.5
00035 #define WDTH_2 8.0
00036 #define SHPE_2 15.0
00037
00038 #define SLPE_3 0.001
00039 #define ICPT_3 1.2
00040
00041
00042
00043
00044 #include "test_functions.h"
00045
00046 int main(int argc, char *argv[])
00047 {
00048 int i;
00049 double x, y, n, s;
00050 double p1[4], p2[4], p3[4];
00051 gsl_rng *r;
00052 FILE *fp;
00053
00054 p1[0] = AREA_1;
00055 p1[1] = CNTR_1;
00056 p1[2] = WDTH_1;
00057 p1[3] = SHPE_1;
00058
00059 p2[0] = AREA_2;
00060 p2[1] = CNTR_2;
00061 p2[2] = WDTH_2;
00062 p2[3] = SHPE_2;
00063
00064 p3[0] = SLPE_3;
00065 p3[1] = ICPT_3;
00066
00067 r = gsl_rng_alloc(gsl_rng_rand);
00068 gsl_rng_set(r, time(NULL));
00069
00070 fp = fopen("data.txt", "w");
00071 if (fp==NULL) exit(1);
00072
00073 for (i=0; i<100; i++)
00074 {
00075 x = ((double)i);
00076
00077
00078 n = gsl_ran_gaussian(r, 0.015);
00079 y = pearson_area(x, p1, 0, 0);
00080 y += pearson_area(x, p2, 0, 0);
00081 y += line(x, p3);
00082 y += n;
00083
00084 s = 0.015;
00085
00086
00087 fprintf(fp, "%f\t%f\t%f\n", x, y, s);
00088 }
00089
00090 fclose(fp);
00091
00092 gsl_rng_free(r);
00093
00094 return EXIT_SUCCESS;
00095 }
00096
00097
00098 #include "test_functions.c"