Debian Codegraph @

src/dr/inference/model/TruncatedDistributionLikelihood.java

raw symbols SCIP
1 package dr.inference.model;
2
3
4 import dr.inference.distribution.DistributionLikelihood;
5 import dr.util.Attribute;
6
7 import java.util.ArrayList;
8
9 /**
10 * @author Max Tolkoff
11 */
12
13 public class TruncatedDistributionLikelihood extends DistributionLikelihood {
14 public TruncatedDistributionLikelihood(DistributionLikelihood distribution, Parameter low, Parameter high){
15 super(distribution.getDistribution());
16 this.dataList = (ArrayList<Attribute<double[]>>) distribution.getDataList();
17 // for(Attribute<double[]> data : list){
18 // System.out.println("here");
19 // this.addData(data);
20 // }
21 this.low = low;
22 this.high = high;
23 }
24
25 @Override
26 protected double getLogPDF(double value, int i){
27 if(high.getParameterValue(i % high.getDimension()) == low.getParameterValue(i % low.getDimension()))
28 return 0;
29 if(value > low.getParameterValue(i % low.getDimension()) && value < high.getParameterValue(i % high.getDimension())){
30 double p1 = getDistribution().logPdf(value);
31 // System.out.println(p1);
32 double p2 = 0;
33 if(!Double.isInfinite(low.getParameterValue(i % low.getDimension())))
34 p2 = getDistribution().cdf(low.getParameterValue(i % low.getDimension()));
35 // System.out.println(p2);
36 double p3 = 0;
37 if(!Double.isInfinite(high.getParameterValue(i % high.getDimension())))
38 p3 = 1 - getDistribution().cdf(high.getParameterValue(i % high.getDimension()));
39 // System.out.println(p3);
40 return p1 - Math.log(1 - (p3 + p2));
41 }
42 else{
43 // System.out.println(high.getParameterValue(i % high.getDimension()));
44 // System.out.println(low.getParameterValue(i % low.getDimension()));
45 return Double.NEGATIVE_INFINITY;
46 }
47 }
48
49 Parameter low;
50 Parameter high;
51 }