Debian Codegraph @

src/dr/evomodel/continuous/MultivariateTDiffusionModel.java

raw symbols SCIP
1 /*
2 * MultivariateTDiffusionModel.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.continuous;
27
28 import dr.inference.model.MatrixParameterInterface;
29 import dr.inference.model.Parameter;
30 import dr.math.distributions.TDistribution;
31 import dr.xml.*;
32
33 /**
34 * @author Marc A. Suchard
35 */
36 public class MultivariateTDiffusionModel extends MultivariateDiffusionModel {
37
38 public static final String DIFFUSION_PROCESS = "multivariateTDiffusionModel";
39 public static final String DIFFUSION_CONSTANT = "precisionParameter";
40 // public static final String BIAS = "mu";
41 // public static final String PRECISION_TREE_ATTRIBUTE = "precision";
42 public static final String DF = "dfParameter";
43
44 public MultivariateTDiffusionModel(Parameter df, MatrixParameterInterface precision) {
45 super();
46 this.dfParameter = df;
47 this.precisionParameter = precision;
48 addVariable(dfParameter);
49 addVariable(precisionParameter);
50
51 }
52
53 public double getLogLikelihood(double[] start, double[] stop, double time) {
54
55 double df = dfParameter.getParameterValue(0);
56 // double scale0 = diffusionPrecisionMatrixParameter.getParameterValue(0,0);
57 // double scale1 = diffusionPrecisionMatrixParameter.getParameterValue(1,1);
58 double scale0 = precisionParameter.getParameterValue(0);
59 double scale1 = precisionParameter.getParameterValue(1);
60 // todo Make this truely multivariate
61 return TDistribution.logPDF(stop[0], start[0], time / scale0, df) +
62 TDistribution.logPDF(stop[1], start[1], time / scale1, df);
63 }
64
65 // *****************************************************************
66 // Interface Model
67 // *****************************************************************
68
69 // No need to just call super of function, is there?
70
71 // public void handleModelChangedEvent(Model model, Object object, int index) {
72 // super.handleModelChangedEvent(model, object, index); //To change body of overridden methods use File | Settings | File Templates.
73 // }
74 /*
75 protected final void handleVariableChangedEvent(Parameter parameter, int index, Parameter.ChangeType type) {
76 // if( parameter.getId().compareTo("allTraits")!= 0)
77 // System.err.println("parameter = "+parameter.getId());
78 super.handleVariableChangedEvent(parameter, index, type); //To change body of overridden methods use File | Settings | File Templates.
79 }
80 */
81
82 public MatrixParameterInterface getPrecisionParameter() {
83 return precisionParameter;
84 }
85
86 protected void calculatePrecisionInfo() {
87 // Nothing to do?
88 }
89
90 public static XMLObjectParser PARSER = new AbstractXMLObjectParser() {
91
92 public String getParserName() {
93 return DIFFUSION_PROCESS;
94 }
95
96 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
97
98 XMLObject cxo = xo.getChild(DIFFUSION_CONSTANT);
99 MatrixParameterInterface diffusionParam = (MatrixParameterInterface) cxo.getChild(MatrixParameterInterface.class);
100 cxo = xo.getChild(DF);
101 Parameter df = (Parameter) cxo.getChild(Parameter.class);
102
103 return new MultivariateTDiffusionModel(df, diffusionParam);
104 }
105
106 //************************************************************************
107 // AbstractXMLObjectParser implementation
108 //************************************************************************
109
110 public String getParserDescription() {
111 return "Describes a multivariate t-distribution diffusion process.";
112 }
113
114 public XMLSyntaxRule[] getSyntaxRules() {
115 return rules;
116 }
117
118 private final XMLSyntaxRule[] rules = {
119 new ElementRule(DIFFUSION_CONSTANT,
120 new XMLSyntaxRule[]{new ElementRule(Parameter.class)}),
121 new ElementRule(DF,
122 new XMLSyntaxRule[]{new ElementRule(Parameter.class)})
123 };
124
125 public Class getReturnType() {
126 return MultivariateTDiffusionModel.class;
127 }
128 };
129
130 // **************************************************************
131 // Private instance variables
132 // **************************************************************
133
134 private final Parameter dfParameter;
135 private final MatrixParameterInterface precisionParameter;
136
137 }