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_