diff --git a/ex-1/main.c b/ex-1/main.c index c45396e..b9e3b94 100644 --- a/ex-1/main.c +++ b/ex-1/main.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "landau.h" #include "tests.h" @@ -140,13 +141,29 @@ int main(int argc, char** argv) { // print the results fprintf(stderr, "\n\n# FWHM comparison\n"); double fwhm_e = numeric_fwhm(min, max, mode_e); + fprintf(stderr, "\n# Results\n"); fprintf(stderr, "expected FWHM: %.7f\n", fwhm_e); fprintf(stderr, "observed FWHM: %.3f\n", fwhm_o); - // print the counts - // gsl_histogram_fprintf(stdout, hist, "%g", "%g"); + /* Median comparison + * + * Compute the median of the sample + * and compare it with QDF(1/2). + */ + fprintf(stderr, "\n\n# Median comparison\n"); + double med_e = landau_qdf(0.5); + double med_o = gsl_stats_median_from_sorted_data( + sample, // sorted data + 1, // array stride + samples); // number of elements + + // print the results + fprintf(stderr, "\n# Results\n"); + fprintf(stderr, "expected median: %.7f\n", med_e); + fprintf(stderr, "observed median: %.7f\n", med_o); + // clean up and exit gsl_histogram_free(hist);