| 1 | package de.uka.ipd.sdq.statistics.test; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import de.uka.ipd.sdq.statistics.IBatchAlgorithm; |
| 6 | import de.uka.ipd.sdq.statistics.PhiMixingBatchAlgorithm; |
| 7 | import de.uka.ipd.sdq.statistics.estimation.SampleMeanEstimator; |
| 8 | import junit.framework.TestCase; |
| 9 | |
| 10 | public class TestPhiMixingBatchAlgorithm extends TestCase { |
| 11 | |
| 12 | private IBatchAlgorithm batchAlgorithm; |
| 13 | |
| 14 | @Override |
| 15 | protected void setUp() throws Exception { |
| 16 | super.setUp(); |
| 17 | |
| 18 | batchAlgorithm = new PhiMixingBatchAlgorithm(); |
| 19 | } |
| 20 | |
| 21 | public void testPhiMixing() { |
| 22 | List<Double> samples = TestUtils.createSampleSequence(32000, 4); |
| 23 | batchAlgorithm.offerSamples(samples); |
| 24 | |
| 25 | double expectedMean = new SampleMeanEstimator().estimatePoint(samples); |
| 26 | double actualMean = new SampleMeanEstimator().estimatePoint(batchAlgorithm |
| 27 | .getBatchMeans()); |
| 28 | |
| 29 | assertTrue(batchAlgorithm.hasValidBatches()); |
| 30 | assertEquals(expectedMean, actualMean, 0.01); |
| 31 | } |
| 32 | |
| 33 | } |