diff --git a/DESCRIPTION b/DESCRIPTION index 3e2b79b9..5e9257cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,6 +20,6 @@ Suggests: testthat Encoding: UTF-8 RoxygenNote: 7.3.1 -URL: http://imbs-hl.github.io/ranger/, +URL: https://imbs-hl.github.io/ranger/, https://github.com/imbs-hl/ranger BugReports: https://github.com/imbs-hl/ranger/issues diff --git a/cpp_version/src/version.h b/cpp_version/src/version.h index 3601cfab..f2280277 100644 --- a/cpp_version/src/version.h +++ b/cpp_version/src/version.h @@ -1,3 +1,3 @@ #ifndef RANGER_VERSION -#define RANGER_VERSION "0.16.0" +#define RANGER_VERSION "0.16.1" #endif diff --git a/src/utility.cpp b/src/utility.cpp index 9e7853b2..c3450122 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -683,8 +683,20 @@ double betaLogLik(double y, double mean, double phi) { phi = 1 - std::numeric_limits::epsilon(); } - return (lgamma(phi) - lgamma(mean * phi) - lgamma((1 - mean) * phi) + (mean * phi - 1) * log(y) - + ((1 - mean) * phi - 1) * log(1 - y)); + return (mylgamma(phi) - mylgamma(mean * phi) - mylgamma((1 - mean) * phi) + (mean * phi - 1) * log(y) + + ((1 - mean) * phi - 1) * log(1 - y)); +} + +double mylgamma(double x) { +#ifdef WIN_R_BUILD + // lgamma_r not available in mingw + return(lgamma(x)); +#else + int gamma_sign; // Sign for gamma function, not used + using namespace std; // Because lgamma_r is sometimes in global namespace, sometimes in std + return(lgamma_r(x, &gamma_sign)); +#endif + } } // namespace ranger diff --git a/src/utility.h b/src/utility.h index 1460c302..de22237c 100644 --- a/src/utility.h +++ b/src/utility.h @@ -525,6 +525,12 @@ std::stringstream& readFromStream(std::stringstream& in, double& token); */ double betaLogLik(double y, double mean, double phi); +/* + * Returns the natural logarithm of the absolute value of the gamma function of x. + * @param x Parameter for the log-gamma function. + */ +double mylgamma(double x); + // User interrupt from R #ifdef R_BUILD static void chkIntFn(void *dummy) {