From f251769a1c4850efae4a40b9b6bc98c2aaa4a4bc Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 2 Nov 2015 16:17:59 +0000 Subject: [PATCH] Math: chi^2 p-value function from GSL --- lib/Math.cpp | 9 +++++++++ lib/Math.hpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/Math.cpp b/lib/Math.cpp index db3a931..6658c3b 100644 --- a/lib/Math.cpp +++ b/lib/Math.cpp @@ -19,6 +19,7 @@ #include #include +#include using namespace std; using namespace Latan; @@ -90,3 +91,11 @@ DEF_STD_FUNC_2ARG(fmin) // Absolute value DEF_STD_FUNC_1ARG(fabs) + +// p-value +auto chi2PValueVecFunc = [](const double arg[2]) +{ + return gsl_cdf_chisq_Q(arg[0], arg[1]); +}; + +DoubleFunction MATH_NAMESPACE::chi2PValue(chi2PValueVecFunc, 2); diff --git a/lib/Math.hpp b/lib/Math.hpp index 84f2270..7f7f018 100644 --- a/lib/Math.hpp +++ b/lib/Math.hpp @@ -141,6 +141,15 @@ DECL_STD_FUNC(fmin) // Absolute value DECL_STD_FUNC(fabs) +/****************************************************************************** + * Other functions * + ******************************************************************************/ +// p-value +namespace MATH_NAMESPACE +{ + extern DoubleFunction chi2PValue; +} + END_LATAN_NAMESPACE #endif // Latan_Math_hpp_