Debian Codegraph @

src/dr/evomodel/tree/TipHeightLikelihood.java

raw symbols SCIP
1 /*
2 * TipHeightLikelihood.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
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 dr.evomodel.tree;
27
28 import dr.inference.distribution.ParametricDistributionModel;
29 import dr.inference.model.Likelihood;
30 import dr.inference.model.Parameter;
31 import org.w3c.dom.Document;
32 import org.w3c.dom.Element;
33
34 /**
35 * A class that returns the log likelihood of a set of data (statistics)
36 * being distributed according to the given parametric distribution.
37 * @author Alexei Drummond
38 * @version $Id: TipHeightLikelihood.java,v 1.2 2005/05/17 16:54:41 rambaut Exp $
39 */
40
41 public class TipHeightLikelihood extends Likelihood.Abstract {
42
43 public TipHeightLikelihood(ParametricDistributionModel distribution, Parameter tipHeights) {
44 super(distribution);
45 this.distribution = distribution;
46 this.tipHeights = tipHeights;
47 offsets = new double[tipHeights.getDimension()];
48 for (int i = 0; i < tipHeights.getDimension(); i++) {
49 offsets[i] = tipHeights.getParameterValue(i);
50 }
51 }
52
53 // **************************************************************
54 // Likelihood IMPLEMENTATION
55 // **************************************************************
56
57 /**
58 * Calculate the log likelihood of the current state.
59 * @return the log likelihood.
60 */
61 public double calculateLogLikelihood() {
62
63 double logL = 0.0;
64
65 for (int i = 0; i < tipHeights.getDimension(); i++) {
66 logL += distribution.logPdf(tipHeights.getParameterValue(i) - offsets[i]);
67 }
68
69 return logL;
70 }
71
72
73 /**
74 * Overridden to always return false.
75 */
76 protected boolean getLikelihoodKnown() {
77 return false;
78 }
79
80 // **************************************************************
81 // XMLElement IMPLEMENTATION
82 // **************************************************************
83
84 public Element createElement(Document d) {
85 throw new RuntimeException("Not implemented yet!");
86 }
87
88 ParametricDistributionModel distribution;
89 private final Parameter tipHeights;
90 private final double[] offsets;
91 }
92