From e4fc0098dddae408a5952795fdf6139011bc83dc Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 1 Apr 2020 01:34:57 +0200 Subject: [PATCH] ex-1: improve QDF accuracy and print error --- ex-1/landau.c | 4 +++- ex-1/main.c | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ex-1/landau.c b/ex-1/landau.c index 9f7b3d2..5728721 100644 --- a/ex-1/landau.c +++ b/ex-1/landau.c @@ -88,8 +88,10 @@ double landau_qdf(double p0) { stat = gsl_root_fsolver_iterate(s); low = gsl_root_fsolver_x_lower(s); upp = gsl_root_fsolver_x_upper(s); - stat = gsl_root_test_interval(low, upp, 0, 0.01); + stat = gsl_root_test_interval(low, upp, 0, 0.001); } + fprintf(stderr, "QDF error: %.3g\n", upp - low); + return gsl_root_fsolver_root(s); } diff --git a/ex-1/main.c b/ex-1/main.c index b9e3b94..2d9af4d 100644 --- a/ex-1/main.c +++ b/ex-1/main.c @@ -97,7 +97,7 @@ int main(int argc, char** argv) { } } fprintf(stderr, "\n\n# Mode comparison\n"); - fprintf(stderr, "\nstep: %.2f\n ", (max - min)/bins); + fprintf(stderr, "step: %.2f\n ", (max - min)/bins); f_mode_o = f_mode_o/samples; mode_o = min + (maxbin + 0.5)*(max - min)/bins; @@ -142,7 +142,7 @@ int main(int argc, char** argv) { fprintf(stderr, "\n\n# FWHM comparison\n"); double fwhm_e = numeric_fwhm(min, max, mode_e); - fprintf(stderr, "\n# Results\n"); + fprintf(stderr, "\n## Results\n"); fprintf(stderr, "expected FWHM: %.7f\n", fwhm_e); fprintf(stderr, "observed FWHM: %.3f\n", fwhm_o); @@ -160,7 +160,7 @@ int main(int argc, char** argv) { samples); // number of elements // print the results - fprintf(stderr, "\n# Results\n"); + fprintf(stderr, "\n## Results\n"); fprintf(stderr, "expected median: %.7f\n", med_e); fprintf(stderr, "observed median: %.7f\n", med_o);