commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Maisonobe (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (MATH-226) CorrelatedRandomVectorGenerator generates invariant samples
Date Tue, 16 Sep 2008 21:07:44 GMT

     [ https://issues.apache.org/jira/browse/MATH-226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Luc Maisonobe resolved MATH-226.
--------------------------------

    Resolution: Fixed

There was an error in the Choleski decomposition with rows reordering. The wrong permutation
was used
(swap[i] instead of index[i] in the root matrix construction at the end of the decompose method).

The problem is now fixed in subversion repository, in branch MATH_2_0 as of r696054, and a
new test has been added using your data.

Thanks for reporting the problem.

> CorrelatedRandomVectorGenerator generates invariant samples
> -----------------------------------------------------------
>
>                 Key: MATH-226
>                 URL: https://issues.apache.org/jira/browse/MATH-226
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: WIN32
>            Reporter: Stuart Siegel
>
> 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++) {
> 			for (int c = 0; c < s[r].length; c++)
> 				System.out.print(s[r][c] + ",");
> 			System.out.println();
> 		}
> 	}
> 	public static void main(String[] args) {
> 		double[] mean = { 1, 1, 10, 1 };
> 		double[][] cov = { { 1, 3, 2, 6 }, { 3, 13, 16, 2 }, { 2, 16, 38, -1 },
> 				{ 6, 2, -1, 197 } };
> 		
> 		double[][] s = new double[3][4];
> 		TestMath.sampler(mean, cov, s);
> 		TestMath.print(s);
> 		
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message