[mlpack-svn] r10432 - mlpack/trunk/src/mlpack/tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Nov 28 00:39:43 EST 2011


Author: rcurtin
Date: 2011-11-28 00:39:43 -0500 (Mon, 28 Nov 2011)
New Revision: 10432

Modified:
   mlpack/trunk/src/mlpack/tests/gmm_test.cpp
Log:
Make sure the covariance matrix is positive semidefinite.


Modified: mlpack/trunk/src/mlpack/tests/gmm_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/gmm_test.cpp	2011-11-28 05:16:12 UTC (rev 10431)
+++ mlpack/trunk/src/mlpack/tests/gmm_test.cpp	2011-11-28 05:39:43 UTC (rev 10432)
@@ -212,8 +212,11 @@
     means[i] -= 0.5;
     means[i] *= 50;
 
+    // We need to make sure the covariance is positive definite.  We will take a
+    // random matrix C and then set our covariance to 4 * C * C', which will be
+    // positive semidefinite.
     covars[i].randu(dims, dims);
-    covars[i] *= 2;
+    covars[i] *= 4 * trans(covars[i]);
 
     data.cols(point, point + counts[i] - 1) = (covars[i] * gaussian + means[i]
         * arma::ones<arma::rowvec>(counts[i]));




More information about the mlpack-svn mailing list