commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r696054 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java site/xdoc/changes.xml test/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
Date Tue, 16 Sep 2008 21:00:29 GMT
Author: luc
Date: Tue Sep 16 14:00:28 2008
New Revision: 696054

URL: http://svn.apache.org/viewvc?rev=696054&view=rev
Log:
Fixed an error in CorrelatedRandomVectorGenerator leading to a component of the generated
vector being constant
JIRA: MATH-226

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
    commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java?rev=696054&r1=696053&r2=696054&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
Tue Sep 16 14:00:28 2008
@@ -253,7 +253,7 @@
         // build the root matrix
         root = new RealMatrixImpl(order, rank);
         for (int i = 0; i < order; ++i) {
-            System.arraycopy(b[i], 0, root.getDataRef()[swap[i]], 0, rank);
+            System.arraycopy(b[i], 0, root.getDataRef()[index[i]], 0, rank);
         }
 
     }

Modified: commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml?rev=696054&r1=696053&r2=696054&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml Tue Sep 16 14:00:28 2008
@@ -39,6 +39,10 @@
   </properties>
   <body>
     <release version="2.0" date="TBD" description="TBD">
+      <action dev="luc" type="fix" issue="MATH-226" due-to="Stuart Siegel">
+        Fixed an error in CorrelatedRandomVectorGenerator leading to a component of
+        the generated vector being constant.
+      </action>
       <action dev="luc" type="fix" issue="MATH-223" due-to="John Mulcahy">
         Greatly improved QR-decomposition speed using transposed matrices internally.
       </action>

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java?rev=696054&r1=696053&r2=696054&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
Tue Sep 16 14:00:28 2008
@@ -39,6 +39,29 @@
         assertEquals(3, generator.getRank());
     }
 
+    public void testMath226()
+        throws DimensionMismatchException, NotPositiveDefiniteMatrixException {
+        double[] mean = { 1, 1, 10, 1 };
+        double[][] cov = {
+                { 1, 3, 2, 6 },
+                { 3, 13, 16, 2 },
+                { 2, 16, 38, -1 },
+                { 6, 2, -1, 197 }
+        };
+        RealMatrix covRM = new RealMatrixImpl(cov, false);
+        JDKRandomGenerator jg = new JDKRandomGenerator();
+        jg.setSeed(5322145245211l);
+        NormalizedRandomGenerator rg = new GaussianRandomGenerator(jg);
+        CorrelatedRandomVectorGenerator sg =
+            new CorrelatedRandomVectorGenerator(mean, covRM, 0.00001, rg);
+
+        for (int i = 0; i < 10; i++) {
+            double[] generated = sg.nextVector();
+            assertTrue(Math.abs(generated[0] - 1) > 0.1);
+        }
+
+    }
+
     public void testRootMatrix() {
         RealMatrix b = generator.getRootMatrix();
         RealMatrix bbt = b.multiply(b.transpose());



Mime
View raw message