| 1 | package de.uka.ipd.sdq.statistics.estimation.test; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.List; |
| 5 | |
| 6 | import junit.framework.TestCase; |
| 7 | import de.uka.ipd.sdq.statistics.estimation.SampleMeanEstimator; |
| 8 | |
| 9 | public class TestMeanEstimator extends TestCase { |
| 10 | |
| 11 | private SampleMeanEstimator estimator; |
| 12 | |
| 13 | @Override |
| 14 | protected void setUp() throws Exception { |
| 15 | super.setUp(); |
| 16 | estimator = new SampleMeanEstimator(); |
| 17 | } |
| 18 | |
| 19 | public void testMeanPointEstimation() { |
| 20 | List<Double> samples = new ArrayList<Double>(); |
| 21 | samples.add(1.0); |
| 22 | samples.add(2.0); |
| 23 | samples.add(3.0); |
| 24 | samples.add(4.0); |
| 25 | samples.add(5.0); |
| 26 | |
| 27 | double expectedMean = (1.0 + 2.0 + 3.0 + 4.0 + 5.0) / 5.0; |
| 28 | double actualMean = estimator.estimatePoint(samples); |
| 29 | |
| 30 | assertEquals(expectedMean, actualMean); |
| 31 | } |
| 32 | |
| 33 | } |