@@ -0,0 +1,1616 @@
+package test.blog.distrib;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport blog.common.Util;%0Aimport blog.common.numerical.JamaMatrixLib;%0Aimport blog.common.numerical.MatrixLib;%0Aimport blog.distrib.Laplace;%0Aimport blog.model.BuiltInTypes;%0A%0A/**%0A * A test class to verify the Laplace distribution %0A * %0A * @author awong%0A */%0Apublic class LaplaceTest %7B%0A%09%0A%09private static final double MEAN = 0.0;%0A%09%0A%09private static final double DIVERSITY = 1.0;%0A%09//private static final double MAX_DIFF_DOUBLE = 1e-10;%0A%09%0A%09private Laplace distrib;%0A%09private static final int NUM_OF_SAMPLES = 1000;%0A%09%0A%09@Before%0A%09public void createLaplace() %7B%0A%09%09distrib = new Laplace(MEAN, DIVERSITY);%0A%0A%09%7D%0A%09%0A%09%0A%09@Test%0A%09public void testSampleVal() %7B%0A%09%09Util.initRandom(true);%0A%09%09double sample, sample_mean = 0, sample_variance = 0;%0A%09%09System.out.println(%22Number of samples: %22 + NUM_OF_SAMPLES);%0A%09%09System.out.print(%22Samples: %22);%0A%09%09for(int i = 0; i %3C NUM_OF_SAMPLES; i++) %7B%0A%09%09%09sample = distrib.sampleVal();%0A%09%09%09System.out.print(sample + %22%5Ct%22);%0A%09%09%09sample_mean += sample;%0A%09%09%09sample_variance += sample * sample;%0A%09%09%7D%0A%09%09sample_mean /= NUM_OF_SAMPLES;%0A%09%09sample_variance = (sample_variance - NUM_OF_SAMPLES * sample_mean * sample_mean) / (NUM_OF_SAMPLES - 1);%0A%09%09System.out.println();%0A%09%09System.out.println(%22Sample mean: %22 + sample_mean + %22, true mean: %22 + distrib.getMean());%0A%09%09System.out.println(%22Sample variance: %22 + sample_variance + %22, true variance: %22 + distrib.getVariance());%0A%09%7D%0A%09%0A%09@Test%0A%09public void testToString() %7B%0A%09%09System.out.println(distrib.toString());%0A%09%7D%0A%7D%0A

Add a test for Laplace distribution -- by Da Tang