Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.2
-
None
-
None
-
None
-
WIN32
Description
For the following code sample, the output is:
1.0,3.9432161557722925,16.66859790068678,1.0743673824292688,
1.0,-1.4103098147521094,-2.670854139636077,1.8368602953644368,
1.0,0.230029048125738,12.67864233710285,0.1124537698401884,
Why is the first column of each row fixed at 1.0?
Here is the code that generated this:
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.RealMatrixImpl;
import org.apache.commons.math.random.CorrelatedRandomVectorGenerator;
import org.apache.commons.math.random.GaussianRandomGenerator;
import org.apache.commons.math.random.JDKRandomGenerator;
public class TestMath {
public static void sampler(double[] mean, double[][] cov, double[][] s) {
RealMatrix covRM = new RealMatrixImpl(cov);
try {
CorrelatedRandomVectorGenerator sg = new CorrelatedRandomVectorGenerator(
mean, covRM, 0.00001, new GaussianRandomGenerator(
new JDKRandomGenerator()));
for (int i = 0; i < s.length; i++)
{ s[i] = sg.nextVector(); }} catch (Exception e)
{ e.printStackTrace(); System.exit(-1); }}
static void print(double[][] s) {
for (int r = 0; r < s.length; r++)
}
public static void main(String[] args) {
double[] mean =
;
double[][] cov = {
,
{ 3, 13, 16, 2 },
{ 2, 16, 38, -1 },
};
double[][] s = new double[3][4];
TestMath.sampler(mean, cov, s);
TestMath.print(s);
}
}