1 /* 2 * This file is part of ELKI: 3 * Environment for Developing KDD-Applications Supported by Index-Structures 4 * 5 * Copyright (C) 2018 6 * ELKI Development Team 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 package de.lmu.ifi.dbs.elki.math.statistics.distribution.estimator; 22 23 import org.junit.Test; 24 25 import de.lmu.ifi.dbs.elki.math.statistics.distribution.LaplaceDistribution; 26 import de.lmu.ifi.dbs.elki.utilities.datastructures.arraylike.DoubleArrayAdapter; 27 28 /** 29 * Regression test the estimation for the Laplace MAD estimation. 30 * 31 * @author Erich Schubert 32 */ 33 public class LaplaceMADEstimatorTest extends AbstractDistributionEstimatorTest { 34 @Test testEstimator()35 public void testEstimator() { 36 final LaplaceMADEstimator est = instantiate(LaplaceMADEstimator.class, LaplaceDistribution.class); 37 load("lap.ascii.gz"); 38 double[] data; 39 LaplaceDistribution dist; 40 data = this.data.get("random_1_3"); 41 dist = est.estimate(data, DoubleArrayAdapter.STATIC); 42 assertStat("rate", dist.getRate(), 1, 0.046455781235775984); 43 assertStat("loc", dist.getLocation(), 3, -0.04027330298719978); 44 data = this.data.get("random_4_05"); 45 dist = est.estimate(data, DoubleArrayAdapter.STATIC); 46 assertStat("rate", dist.getRate(), 4, 0.0021131826782738727); 47 assertStat("loc", dist.getLocation(), .5, -0.045715312384149276); 48 } 49 } 50