use of dr.math.distributions.PoissonDistribution in project beast-mcmc by beast-dev.
the class ApproximatePoissonTreeLikelihoodTest method testRootPolytomy.
public void testRootPolytomy() throws IOException, Importer.ImportException, TreeUtils.MissingTaxonException {
branchRateModel = new StrictClockBranchRates(new Parameter.Default(1.0));
NewickImporter importer = new NewickImporter("((1:1.0,2:1.0):1.0,3:1.0,4:1.0);");
NewickImporter importer2 = new NewickImporter("(((1:1.0,2:1.0):1.0,3:1.1):0.1,4:1.0);");
tree = importer.importTree(null);
treeModel = new BigFastTreeModel(importer2.importTree(null));
CladeNodeModel cladeModel = new CladeNodeModel(tree, treeModel);
BranchLengthProvider constrainedBranchLengthProvider = new ConstrainedTreeBranchLengthProvider(cladeModel);
approximatePoissonTreeLikelihood = new ApproximatePoissonTreeLikelihood("approximateTreeLikelihood", 1, treeModel, branchRateModel, constrainedBranchLengthProvider);
approximatePoissonTreeLikelihood.getLogLikelihood();
expectedLL = 0;
double[] expectations = { 1d, 1d, 1d, 1.1, 1.1 };
// time
double[] mutations = { 1d, 1d, 1d, 1.0, 1 };
for (int i = 0; i < expectations.length; i++) {
PoissonDistribution p = new PoissonDistribution(expectations[i]);
expectedLL += p.logPdf(mutations[i]);
}
NodeRef rootNode = treeModel.getRoot();
NodeRef rootNode1 = treeModel.getNode(5);
NodeRef tip3 = treeModel.getNode(2);
CladeRef clade = cladeModel.getClade(rootNode);
treeModel.beginTreeEdit();
treeModel.removeChild(rootNode, rootNode1);
treeModel.setRoot(rootNode1);
treeModel.removeChild(rootNode1, tip3);
treeModel.addChild(rootNode, tip3);
treeModel.addChild(rootNode1, rootNode);
treeModel.setNodeHeight(rootNode1, treeModel.getNodeHeight(rootNode) + 1);
treeModel.endTreeEdit();
// cladeModel.setRootNode(clade,rootNode1);
double LL = approximatePoissonTreeLikelihood.getLogLikelihood();
approximatePoissonTreeLikelihood.makeDirty();
double newLL = approximatePoissonTreeLikelihood.getLogLikelihood();
assertEquals(LL, newLL, 1E-13);
}
use of dr.math.distributions.PoissonDistribution in project beast-mcmc by beast-dev.
the class IndianBuffetProcessPrior method getSizeLogLikelihood.
@Override
public double getSizeLogLikelihood() {
PoissonDistribution poisson = new PoissonDistribution(alpha.getParameterValue(0) * H());
calculateLogLikelihood();
return poisson.logPdf(KPlus) - Math.log(1 - Math.exp(-poisson.mean()));
}
Aggregations