@Test
	public void TestMultiVariateNormalEstimator() throws Exception
	{
		// model 1 is a zero mean unit variance gaussian
		MultivariateNormalEstimator model1 = new MultivariateNormalEstimator();
		model1.setMean(new DoubleVector(4, 0.0));
		model1.setVariance(Matrix.identity(4, 4));
		
		DoubleVector train1 [] = new DoubleVector[1000];
		for (int i = 0; i < train1.length; i++)
		{
			train1[i] = model1.sample();
		}
		DoubleVector test1 [] = new DoubleVector[1000];
		for (int i = 0; i < train1.length; i++)
		{
			test1[i] = model1.sample();
		}
	

		// model2 has different means and covariances
		MultivariateNormalEstimator model2 = new MultivariateNormalEstimator();
		DoubleVector mean = DoubleVector.random(4);
		model2.setMean(mean);
		Matrix m = Matrix.identity(4, 4);
		for (int i = 0; i < 3; i++)
		{
			m.set(i,i, 2.0);
			m.set(i, i+1, -1);
			m.set(i+1, i, -1);
		}
		m.set(3,3, 2);
		//m.set(0, 1, 1);
		//m.set(1, 0, 1);
		model2.setVariance(m);
		
		
		DoubleVector train2 [] = new DoubleVector[1000];
		for (int i = 0; i < train2.length; i++)
		{
			train2[i] = model2.sample();
		}
		DoubleVector test2 [] = new DoubleVector[1000];
		for (int i = 0; i < test2.length; i++)
		{
			test2[i] = model2.sample();
		}
		
		MultivariateNormalEstimator est1 = new MultivariateNormalEstimator();
		for (int i = 0; i < train1.length; i++)
		{
			est1.addValue(train1[i], 1.0);
		}
		MultivariateNormalEstimator est2 = new MultivariateNormalEstimator();
		for (int i = 0; i < train2.length; i++)
		{
			est2.addValue(train2[i], 1.0);
		}
		
		double lik1 = 0.0;
		double lik2 = 0.0;
		for (int i = 0; i < test1.length; i++)
		{
			lik1 += Math.log(est1.getProbability(test1[i]));
			lik2 += Math.log(est2.getProbability(test1[i]));
		}
		assertTrue(lik1 > lik2);
		
		lik1 = 0.0;
		lik2 = 0.0;
		for (int i = 0; i < test2.length; i++)
		{
			lik1 += Math.log(est1.getProbability(test2[i]));
			lik2 += Math.log(est2.getProbability(test2[i]));
		}
		assertTrue(lik1 < lik2);
	}