[mlpack-git] master: Replaces trigamma(a) with polygamma(1, a) to check compatibility (32fee02)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Jul 20 10:40:03 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/ba850f782a53c5a77b7985f7647f609bd96cb5e7...2c026d838925df436d967439899813da5d34c702
>---------------------------------------------------------------
commit 32fee02c8e43725f072cd0ec293005a1a09034cf
Author: Yannis Mentekidis <mentekid at gmail.com>
Date: Wed Jul 20 15:40:03 2016 +0100
Replaces trigamma(a) with polygamma(1, a) to check compatibility
>---------------------------------------------------------------
32fee02c8e43725f072cd0ec293005a1a09034cf
src/mlpack/core/dists/gamma_distribution.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/mlpack/core/dists/gamma_distribution.cpp b/src/mlpack/core/dists/gamma_distribution.cpp
index bb52ce6..922212c 100644
--- a/src/mlpack/core/dists/gamma_distribution.cpp
+++ b/src/mlpack/core/dists/gamma_distribution.cpp
@@ -7,7 +7,7 @@
#include "gamma_distribution.hpp"
#include <boost/math/special_functions/digamma.hpp>
-#include <boost/math/special_functions/trigamma.hpp>
+#include <boost/math/special_functions/polygamma.hpp>
using namespace mlpack;
using namespace mlpack::distribution;
@@ -31,7 +31,8 @@ void GammaDistribution::Train(const arma::mat& rdata)
// Use boost's definitions of digamma and tgamma, and std::log.
using boost::math::digamma;
- using boost::math::trigamma;
+ //using boost::math::trigamma;
+ using boost::math::polygamma;
using std::log;
// Allocate space for alphas and betas (Assume independent rows).
@@ -59,7 +60,8 @@ void GammaDistribution::Train(const arma::mat& rdata)
// Calculate new value for alpha.
double nominator = meanLogx - logMeanx + log(aEst) - digamma(aEst);
- double denominator = pow(aEst, 2) * (1 / aEst - trigamma(aEst));
+ //double denominator = pow(aEst, 2) * (1 / aEst - trigamma(aEst));
+ double denominator = pow(aEst, 2) * (1 / aEst - polygamma(1, aEst));
assert (denominator != 0); // Protect against division by 0.
aEst = 1.0 / ((1.0 / aEst) + nominator / denominator);
More information about the mlpack-git
mailing list