Debian Codegraph @

src/dr/inference/model/OneOnXPrior.java

raw symbols SCIP
1 /*
2 * OneOnXPrior.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.inference.model;
27
28 import java.util.ArrayList;
29
30 /**
31 * @author Alexei Drummond
32 */
33
34 public class OneOnXPrior extends Likelihood.Abstract {
35
36 public OneOnXPrior() {
37
38 super(null);
39 }
40
41 /**
42 * Adds a statistic, this is the data for which the Prod_i (1/x_i) prior is calculated.
43 *
44 * @param data the statistic to compute density of
45 */
46 public void addData(Statistic data) {
47 dataList.add(data);
48 }
49
50
51 protected ArrayList<Statistic> dataList = new ArrayList<Statistic>();
52
53 /**
54 * Overridden to always return false.
55 */
56 protected boolean getLikelihoodKnown() {
57 return false;
58 }
59
60 /**
61 * Calculate the log likelihood of the current state.
62 *
63 * @return the log likelihood.
64 */
65 public double calculateLogLikelihood() {
66
67 double logL = 0.0;
68
69 for (Statistic statistic : dataList) {
70 for (int j = 0; j < statistic.getDimension(); j++) {
71 logL -= Math.log(statistic.getStatisticValue(j));
72 }
73 }
74 return logL;
75 }
76
77
78 public String prettyName() {
79 String s = "OneOnX" + "(";
80 for (Statistic statistic : dataList) {
81 s = s + statistic.getStatisticName() + ",";
82 }
83 return s.substring(0, s.length() - 1) + ")";
84 }
85 }
86