[mlpack] [mlpack/mlpack] adds GammaDistribution::Train(observations, probabilities) (#834)

Ryan Curtin notifications at github.com
Fri Dec 23 15:43:03 EST 2016


rcurtin commented on this pull request.



> +      rdata(j, i) = dist(generator);
+
+  // fit results with only data
+  GammaDistribution gDist;
+  gDist.Train(rdata);
+
+  // fit results with data and each probability as 1
+  GammaDistribution gDist2;
+  arma::vec allProbabilities1(N, arma::fill::ones);
+  gDist2.Train(rdata, allProbabilities1);
+
+  BOOST_REQUIRE_EQUAL(gDist2.Alpha(0), gDist.Alpha(0));
+  BOOST_REQUIRE_EQUAL(gDist2.Beta(0), gDist.Beta(0));
+
+  BOOST_REQUIRE_EQUAL(gDist2.Alpha(1), gDist.Alpha(1));
+  BOOST_REQUIRE_EQUAL(gDist2.Beta(1), gDist.Beta(1));

We should make this `BOOST_REQUIRE_CLOSE()` with a tolerance of `1e-5` or so, because floating-point errors in some implementations could provide slightly different results.  It looks like your current implementation appears to produce the exact same result, but that may not be true in the future if the code is modified (but still valid), so we should be careful to try and make our test future-proof.

-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/834#pullrequestreview-14337810
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://knife.lugatgt.org/pipermail/mlpack/attachments/20161223/e9c78ca4/attachment.html>


More information about the mlpack mailing list