Fixed an error in CorrelatedRandomVectorGenerator leading to a component of the generated vector being constant
JIRA: MATH-226 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@696054 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7684119c58
commit
e1e21f2f68
|
@ -253,7 +253,7 @@ implements RandomVectorGenerator {
|
||||||
// build the root matrix
|
// build the root matrix
|
||||||
root = new RealMatrixImpl(order, rank);
|
root = new RealMatrixImpl(order, rank);
|
||||||
for (int i = 0; i < order; ++i) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@ The <action> type attribute can be add,update,fix,remove.
|
||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="2.0" date="TBD" description="TBD">
|
<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">
|
<action dev="luc" type="fix" issue="MATH-223" due-to="John Mulcahy">
|
||||||
Greatly improved QR-decomposition speed using transposed matrices internally.
|
Greatly improved QR-decomposition speed using transposed matrices internally.
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -39,6 +39,29 @@ extends TestCase {
|
||||||
assertEquals(3, generator.getRank());
|
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() {
|
public void testRootMatrix() {
|
||||||
RealMatrix b = generator.getRootMatrix();
|
RealMatrix b = generator.getRootMatrix();
|
||||||
RealMatrix bbt = b.multiply(b.transpose());
|
RealMatrix bbt = b.multiply(b.transpose());
|
||||||
|
|
Loading…
Reference in New Issue