diff --git a/ex-1/main.c b/ex-1/main.c index 88b85ca..7d3c00e 100644 --- a/ex-1/main.c +++ b/ex-1/main.c @@ -1,30 +1,35 @@ #include #include #include -#include #include #include #include "landau.h" +#include "moyal.h" #include "tests.h" #include "bootstrap.h" /* Here we generate random numbers following - * the Landau distribution and run a series of - * test to check if they really belong to such a - * distribution. + * the Landau or the Moyal distribution and run a + * series of test to check if they seem to belong + * to the Landau distribution. */ int main(int argc, char** argv) { size_t samples = 50000; + char* distr = "lan"; + double m_params [2] = {-0.22278298, 1.1191486}; /* Process CLI arguments */ for (size_t i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-n")) samples = atol(argv[++i]); + if (!strcmp(argv[i], "-n")) samples = atol(argv[++i]); + else if (!strcmp(argv[i], "-m")) distr = argv[++i]; else { - fprintf(stderr, "Usage: %s -[hn]\n", argv[0]); - fprintf(stderr, "\t-h\tShow this message.\n"); - fprintf(stderr, "\t-n N\tThe size of sample to generate. (default: 50000)\n"); + fprintf(stderr, "Usage: %s -[hnmp]\n", argv[0]); + fprintf(stderr, " -h\t\tShow this message.\n"); + fprintf(stderr, " -n N\t\tThe size of sample to generate. (default: 50000)\n"); + fprintf(stderr, " -m MODE\tUse Landau 'lan' or Moyal 'moy' distribution. " + "(default: 'lan')\n"); return EXIT_FAILURE; } } @@ -33,23 +38,29 @@ int main(int argc, char** argv) { gsl_rng_env_setup(); gsl_rng *r = gsl_rng_alloc(gsl_rng_default); - // prepare histogram + // prepare data storage double* sample = calloc(samples, sizeof(double)); double min = -10; double max = 10; /* Sample generation - * - * Sample points from the Landau distribution - * using the GSL Landau generator. */ fprintf(stderr, "# Sampling\n"); fprintf(stderr, "generating %ld points... ", samples); double x; - for(size_t i=0; i D) D = d; } + double beta = kolmogorov_cdf(D, samples); // print the results