Debian Codegraph @

src/dr/inference/model/OneOnX3Prior.java

raw symbols SCIP
1 /*
2 * OneOnX3Prior.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 Chieh-Hsi Wu
32 *
33 * This an improper prior 1/(x_i^3) which is the Jeffrey's prior for parameters of Normal distribution
34 * (and Log-normal distribution?)
35 *
36 */
37 public class OneOnX3Prior extends Likelihood.Abstract{
38
39 public OneOnX3Prior() {
40
41 super(null);
42 }
43
44 /**
45 * Adds a statistic, this is the data for which the Prod_i (1/x_i^3) prior is calculated.
46 *
47 * @param data the statistic to compute density of
48 */
49 public void addData(Statistic data) {
50 dataList.add(data);
51 }
52
53
54 protected ArrayList<Statistic> dataList = new ArrayList<Statistic>();
55
56 /**
57 * Overridden to always return false.
58 */
59 protected boolean getLikelihoodKnown() {
60 return false;
61 }
62
63 /**
64 * Calculate the log likelihood of the current state.
65 *
66 * @return the log likelihood.
67 */
68 public double calculateLogLikelihood() {
69
70 double logL = 0.0;
71
72 for (Statistic statistic : dataList) {
73 for (int j = 0; j < statistic.getDimension(); j++) {
74 logL -= 3*Math.log(statistic.getStatisticValue(j));
75 }
76 }
77 return logL;
78 }
79
80
81 public String prettyName() {
82 String s = "OneOnX3" + "(";
83 for (Statistic statistic : dataList) {
84 s = s + statistic.getStatisticName() + ",";
85 }
86 return s.substring(0, s.length() - 1) + ")";
87 }
88 }