1   package baseCode.math.distribution;
2   
3   import cern.colt.matrix.DoubleMatrix2D;
4   import cern.colt.matrix.impl.DenseDoubleMatrix2D;
5   import cern.jet.random.engine.DRand;
6   import cern.jet.random.engine.MersenneTwister;
7   import baseCode.math.distribution.Wishart;
8   import baseCode.util.RegressionTesting;
9   import junit.framework.TestCase;
10  
11  /***
12   * <hr>
13   * <p>
14   * Copyright (c) 2004 Columbia University
15   * 
16   * @author pavlidis
17   * @version $Id: TestWishart.java,v 1.1 2005/03/17 13:58:42 pavlidis Exp $
18   */
19  public class TestWishart extends TestCase {
20  
21     Wishart t1;
22     Wishart t2;
23     Wishart t3;
24     Wishart t4;
25     DoubleMatrix2D cov;
26  
27     protected void setUp() throws Exception {
28        cov = new DenseDoubleMatrix2D( new double[][] {
29              {
30                    1, 2
31              }, {
32                    1, 2
33              }
34        } );
35  
36        t1 = new Wishart( 5, cov, new MersenneTwister() );
37        //t2 = new Wishart(2, 8, cov);
38        // t3 = new Wishart(2, 20, cov);
39        // t4 = new Wishart(8, 5, cov);
40        super.setUp();
41     }
42  
43     public void testNextDoubleMatrix() {
44        DoubleMatrix2D actualReturn = t1.nextDoubleMatrix();
45        System.err.println(actualReturn);
46        DoubleMatrix2D expectedReturn = new DenseDoubleMatrix2D( new double[][] {
47              {
48                    1.426553, 4.848117
49              }, {
50                    4.848117, 16.9009
51              }
52        } );
53        assertTrue( RegressionTesting.closeEnough( expectedReturn, actualReturn, 0.0001 ) );
54     }
55  
56  }