@@ -0,0 +1,2423 @@
+/*%0A * PriorParsers.java%0A *%0A * Copyright (c) 2002-2013 Alexei Drummond, Andrew Rambaut and Marc Suchard%0A *%0A * This file is part of BEAST.%0A * See the NOTICE file distributed with this work for additional%0A * information regarding copyright ownership and licensing.%0A *%0A * BEAST is free software; you can redistribute it and/or modify%0A * it under the terms of the GNU Lesser General Public License as%0A * published by the Free Software Foundation; either version 2%0A * of the License, or (at your option) any later version.%0A *%0A *  BEAST is distributed in the hope that it will be useful,%0A *  but WITHOUT ANY WARRANTY; without even the implied warranty of%0A *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A *  GNU Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with BEAST; if not, write to the%0A * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,%0A * Boston, MA  02110-1301  USA%0A */%0A%0Apackage dr.evomodel.coalescent;%0A%0Aimport jebl.math.Binomial;%0Aimport dr.evolution.coalescent.TreeIntervals;%0Aimport dr.evomodel.tree.TreeModel;%0Aimport dr.inference.model.Likelihood;%0A%0A/**%0A * Calculates the coalescent constant for a given tree(Model).%0A *%0A * @author Guy Baele%0A */%0Apublic final class CoalescentConstantLikelihood extends Likelihood.Abstract %7B%0A%0A%09private TreeModel treeModel;%0A%09private TreeIntervals intervals;%0A%09%0A%09// PUBLIC STUFF%0A%09public CoalescentConstantLikelihood(TreeModel treeModel) %7B%0A%0A%09%09super(treeModel);%0A%09%09this.treeModel = treeModel;%0A%09%09this.intervals = new TreeIntervals(treeModel);%0A%0A%09%7D%0A%0A    // **************************************************************%0A%09// Likelihood IMPLEMENTATION%0A%09// **************************************************************%0A%0A%09/**%0A%09 * Calculates the coalescent constant given the treeModel.%0A%09 */%0A%09public double calculateLogLikelihood() %7B%0A%0A%09%09intervals.setIntervalsUnknown();%0A%09%09final int nIntervals = intervals.getIntervalCount();%0A%09%09//System.err.println(%22Interval count: %22 + nIntervals);%0A%09%09double logPDF = 0.0;%0A        for (int i = 0; i %3C nIntervals; i++) %7B%0A        %09//System.err.println(%22Lineage count %22 + i + %22: %22 + intervals.getLineageCount(i));%0A        %09if (intervals.getLineageCount(i) %3E 2) %7B%0A        %09%09logPDF += Math.log(Binomial.choose2(intervals.getLineageCount(i)));%0A        %09%7D%0A        %7D%0A        //System.err.println(%22logPDF = %22 + (-logPDF));%0A        return -logPDF;%0A        %0A%09%7D%0A%0A%7D

Class that calculates the coalescent constant given a tree(model).