From 9b4fa56b49b45e8c43a0388de70bcb1a8d7775fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gi=C3=B9=20Marcer?= Date: Mon, 8 Jun 2020 18:01:35 +0200 Subject: [PATCH] moyal.c: fix some typos and add it to the makefile --- ex-1/moyal.c | 16 ++++++++++------ makefile | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ex-1/moyal.c b/ex-1/moyal.c index f478ec7..8db780c 100644 --- a/ex-1/moyal.c +++ b/ex-1/moyal.c @@ -3,14 +3,18 @@ * PDF, CDF and QDF functions. */ +#include #include +#include -/* This is a wrapper needed by `moyal_cdf` and +/* The Moyal PDF. + * + * This is a wrapper needed by `moyal_cdf` and * other optimisation functions because the GSL * routines expect a function with parameters. */ -double moyal_pdf(double x, void* params) { +double moyal_pdf(double x, double* params) { double mu = params[0]; double sigma = params[1]; double z = (x - mu)/sigma; @@ -20,20 +24,20 @@ double moyal_pdf(double x, void* params) { /* The cumulative function of the Moyal distribution. */ -double moyal_cdf(double x, void* params) { +double moyal_cdf(double x, double* params) { double mu = params[0]; double sigma = params[1]; double z = (x - mu)/sigma; - return 2*(1 - gsl_cdf_gaussian_P(exp(-x/2))); + return 2 * (1 - gsl_cdf_gaussian_P(exp(-z/2), 1)); } /* The quantile function (inverse CDF) of the Moyal * distribution. */ -double moyal_qdf(double p0, void* params) { +double moyal_qdf(double p0, double* params) { double mu = params[0]; double sigma = params[1]; - double z = -2*log(gsl_cdf_gaussian_Pinv(1 - p/2)); + double z = -2 * log(gsl_cdf_gaussian_Pinv(1 - p0/2, 1)); return z*sigma + mu; } diff --git a/makefile b/makefile index 3ec5dfb..23125fb 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,7 @@ CCOMPILE = \ $(CC) $(CFLAGS) $^ -o $@ ex-1: ex-1/bin/main ex-1/bin/pdf -ex-1/bin/main: ex-1/main.c ex-1/landau.c ex-1/tests.c ex-1/bootstrap.c +ex-1/bin/main: ex-1/main.c ex-1/landau.c ex-1/tests.c ex-1/bootstrap.c ex-1/moyal.c $(CCOMPILE) ex-1/bin/pdf: ex-1/pdf.c $(CCOMPILE)