[mlpack-git] master: fix some distribution test cases (7f0493c)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:13:29 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit 7f0493cf132a72fac7d2d6a207cb5b13e75d8b14
Author: Stephen Tu <tu.stephenl at gmail.com>
Date:   Tue Jan 20 16:43:27 2015 -0800

    fix some distribution test cases


>---------------------------------------------------------------

7f0493cf132a72fac7d2d6a207cb5b13e75d8b14
 src/mlpack/tests/distribution_test.cpp | 40 +++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/mlpack/tests/distribution_test.cpp b/src/mlpack/tests/distribution_test.cpp
index 2ff1eb0..9041bb5 100644
--- a/src/mlpack/tests/distribution_test.cpp
+++ b/src/mlpack/tests/distribution_test.cpp
@@ -159,20 +159,20 @@ BOOST_AUTO_TEST_CASE(GaussianDistributionDistributionConstructor)
 BOOST_AUTO_TEST_CASE(GaussianDistributionProbabilityTest)
 {
   arma::vec mean("5 6 3 3 2");
-  arma::mat cov("6 1 1 0 2;"
-                "0 7 1 0 1;"
+  arma::mat cov("6 1 1 1 2;"
+                "1 7 1 0 0;"
                 "1 1 4 1 1;"
                 "1 0 1 7 0;"
-                "2 0 1 1 6");
+                "2 0 1 0 6");
 
   GaussianDistribution d(mean, cov);
 
-  BOOST_REQUIRE_CLOSE(d.Probability("0 1 2 3 4"), 1.02531207499358e-6, 1e-5);
-  BOOST_REQUIRE_CLOSE(d.Probability("3 2 3 7 8"), 1.82353695848039e-7, 1e-5);
-  BOOST_REQUIRE_CLOSE(d.Probability("2 2 0 8 1"), 1.29759261892949e-6, 1e-5);
-  BOOST_REQUIRE_CLOSE(d.Probability("2 1 5 0 1"), 1.33218060268258e-6, 1e-5);
-  BOOST_REQUIRE_CLOSE(d.Probability("3 0 5 1 0"), 1.12120427975708e-6, 1e-5);
-  BOOST_REQUIRE_CLOSE(d.Probability("4 0 6 1 0"), 4.57951032485297e-7, 1e-5);
+  BOOST_REQUIRE_CLOSE(d.LogProbability("0 1 2 3 4"), -13.432076798791542, 1e-5);
+  BOOST_REQUIRE_CLOSE(d.LogProbability("3 2 3 7 8"), -15.814880322345738, 1e-5);
+  BOOST_REQUIRE_CLOSE(d.LogProbability("2 2 0 8 1"), -13.754462857772776, 1e-5);
+  BOOST_REQUIRE_CLOSE(d.LogProbability("2 1 5 0 1"), -13.283283233107898, 1e-5);
+  BOOST_REQUIRE_CLOSE(d.LogProbability("3 0 5 1 0"), -13.800326511545279, 1e-5);
+  BOOST_REQUIRE_CLOSE(d.LogProbability("4 0 6 1 0"), -14.900192463287908, 1e-5);
 }
 
 /**
@@ -244,33 +244,33 @@ BOOST_AUTO_TEST_CASE(GaussianMultivariateProbabilityTest)
   covariance = "2 1.5; 1 4";
   g.Covariance(std::move(covariance));
 
-  BOOST_REQUIRE_CLOSE(g.Probability(x), 0.0624257046546403, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(x), 0.060154914192541771, 1e-5);
   g.Mean() *= -1;
-  BOOST_REQUIRE_CLOSE(g.Probability(-x), 0.0624257046546403, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(-x), 0.060154914192541771, 1e-5);
 
   g.Mean() = "1 1";
   x = "-1 4";
 
-  BOOST_REQUIRE_CLOSE(g.Probability(x), 0.00144014867515135, 1e-5);
-  BOOST_REQUIRE_CLOSE(g.Probability(-x), 0.00133352162064845, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(x), 0.0022506270186086271, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(-x), 0.0016912950996661141, 1e-5);
 
   // Higher-dimensional case.
   x = "0 1 2 3 4";
   g.Mean() = "5 6 3 3 2";
 
-  covariance = "6 1 1 0 2;"
-               "0 7 1 0 1;"
+  covariance = "6 1 1 1 2;"
+               "1 7 1 0 0;"
                "1 1 4 1 1;"
                "1 0 1 7 0;"
-               "2 0 1 1 6";
+               "2 0 1 0 6";
   g.Covariance(std::move(covariance));
 
-  BOOST_REQUIRE_CLOSE(g.Probability(x), 1.02531207499358e-6, 1e-5);
-  BOOST_REQUIRE_CLOSE(g.Probability(-x), 1.06784794079363e-8, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(x), 1.4673143531128877e-06, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(-x), 7.7404143494891786e-09, 1e-8);
 
   g.Mean() *= -1;
-  BOOST_REQUIRE_CLOSE(g.Probability(-x), 1.02531207499358e-6, 1e-5);
-  BOOST_REQUIRE_CLOSE(g.Probability(x), 1.06784794079363e-8, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(-x), 1.4673143531128877e-06, 1e-5);
+  BOOST_REQUIRE_CLOSE(g.Probability(x), 7.7404143494891786e-09, 1e-8);
 
 }
 



More information about the mlpack-git mailing list