Debian Codegraph @

src/test/dr/evomodel/speciation/YuleLikelihoodTest.java

raw symbols SCIP
1 /*
2 * YuleLikelihoodTest.java
3 *
4 * Copyright (C) 2002-2009 Alexei Drummond and Andrew Rambaut
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package test.dr.evomodel.speciation;
27
28 import dr.evolution.io.NewickImporter;
29 import dr.evolution.tree.FlexibleTree;
30 import dr.evolution.tree.Tree;
31 import dr.evolution.util.Units;
32 import dr.evomodel.speciation.BirthDeathGernhard08Model;
33 import dr.evomodel.speciation.SpeciationLikelihood;
34 import dr.evomodel.speciation.SpeciationModel;
35 import dr.evomodelxml.tree.TreeModelParser;
36 import dr.inference.model.Likelihood;
37 import dr.inference.model.Parameter;
38 import junit.framework.Test;
39 import junit.framework.TestCase;
40 import junit.framework.TestSuite;
41
42 /**
43 * YuleModel Tester.
44 *
45 * @author Alexei Drummond
46 * @version 1.0
47 * @since <pre>08/26/2007</pre>
48 */
49 public class YuleLikelihoodTest extends TestCase {
50
51 static final String TL = "TL";
52 static final String TREE_HEIGHT = TreeModelParser.ROOT_HEIGHT;
53
54 private FlexibleTree tree;
55
56 public YuleLikelihoodTest(String name) {
57 super(name);
58 }
59
60 public void setUp() throws Exception {
61 super.setUp();
62
63 NewickImporter importer = new NewickImporter("((1:1.0,2:1.0):1.0,(3:1.0,4:1.0):1.0);");
64 tree = (FlexibleTree) importer.importTree(null);
65 }
66
67 public void testYuleLikelihood() {
68
69 yuleLikelihoodTester(tree, 1.0, -2.8219461696520542);
70
71 }
72
73 private void yuleLikelihoodTester(Tree tree, double birthRate, double logL) {
74
75 Parameter b = new Parameter.Default("b", birthRate, 0.0, Double.MAX_VALUE);
76 Parameter d = new Parameter.Default("d", 0.0, 0.0, Double.MAX_VALUE);
77
78 SpeciationModel speciationModel = new BirthDeathGernhard08Model(b, d, null, BirthDeathGernhard08Model.TreeType.TIMESONLY,
79 Units.Type.YEARS);
80 Likelihood likelihood = new SpeciationLikelihood(tree, speciationModel, "yule.like");
81
82 assertEquals(likelihood.getLogLikelihood(), logL);
83
84 }
85
86 public static Test suite() {
87 return new TestSuite(YuleLikelihoodTest.class);
88 }
89 }