ex-1: add median test
This commit is contained in:
parent
0ee7f9adb3
commit
9aadcbf8a7
21
ex-1/main.c
21
ex-1/main.c
@ -3,6 +3,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gsl/gsl_randist.h>
|
#include <gsl/gsl_randist.h>
|
||||||
#include <gsl/gsl_histogram.h>
|
#include <gsl/gsl_histogram.h>
|
||||||
|
#include <gsl/gsl_statistics_double.h>
|
||||||
|
|
||||||
#include "landau.h"
|
#include "landau.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
@ -140,13 +141,29 @@ int main(int argc, char** argv) {
|
|||||||
// print the results
|
// print the results
|
||||||
fprintf(stderr, "\n\n# FWHM comparison\n");
|
fprintf(stderr, "\n\n# FWHM comparison\n");
|
||||||
double fwhm_e = numeric_fwhm(min, max, mode_e);
|
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, "expected FWHM: %.7f\n", fwhm_e);
|
||||||
fprintf(stderr, "observed FWHM: %.3f\n", fwhm_o);
|
fprintf(stderr, "observed FWHM: %.3f\n", fwhm_o);
|
||||||
|
|
||||||
|
|
||||||
// print the counts
|
/* Median comparison
|
||||||
// gsl_histogram_fprintf(stdout, hist, "%g", "%g");
|
*
|
||||||
|
* 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
|
// clean up and exit
|
||||||
gsl_histogram_free(hist);
|
gsl_histogram_free(hist);
|
||||||
|
Loading…
Reference in New Issue
Block a user