Search in sources :

Example 6 with PoissonDistribution

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);
}
Also used : PoissonDistribution(dr.math.distributions.PoissonDistribution) ConstrainedTreeBranchLengthProvider(dr.evomodel.bigfasttree.constrainedtree.ConstrainedTreeBranchLengthProvider) CladeNodeModel(dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel) ConstrainedTreeBranchLengthProvider(dr.evomodel.bigfasttree.constrainedtree.ConstrainedTreeBranchLengthProvider) StrictClockBranchRates(dr.evomodel.branchratemodel.StrictClockBranchRates) NodeRef(dr.evolution.tree.NodeRef) NewickImporter(dr.evolution.io.NewickImporter) CladeRef(dr.evomodel.bigfasttree.constrainedtree.CladeRef)

Example 7 with PoissonDistribution

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()));
}
Also used : PoissonDistribution(dr.math.distributions.PoissonDistribution)

Aggregations

PoissonDistribution (dr.math.distributions.PoissonDistribution)7 NewickImporter (dr.evolution.io.NewickImporter)3 NodeRef (dr.evolution.tree.NodeRef)3 CladeNodeModel (dr.evomodel.bigfasttree.constrainedtree.CladeNodeModel)3 ConstrainedTreeBranchLengthProvider (dr.evomodel.bigfasttree.constrainedtree.ConstrainedTreeBranchLengthProvider)3 StrictClockBranchRates (dr.evomodel.branchratemodel.StrictClockBranchRates)3 DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)2 ArrayLogFormatter (dr.inference.loggers.ArrayLogFormatter)2 MCLogger (dr.inference.loggers.MCLogger)2 TabDelimitedFormatter (dr.inference.loggers.TabDelimitedFormatter)2 MCMC (dr.inference.mcmc.MCMC)2 MCMCOptions (dr.inference.mcmc.MCMCOptions)2 ArrayTraceList (dr.inference.trace.ArrayTraceList)2 Trace (dr.inference.trace.Trace)2 TraceCorrelation (dr.inference.trace.TraceCorrelation)2 GammaDistribution (dr.math.distributions.GammaDistribution)2 ArrayList (java.util.ArrayList)2 SitePatterns (dr.evolution.alignment.SitePatterns)1 ARGLogger (dr.evomodel.arg.ARGLogger)1 ARGReassortmentNodeCountStatistic (dr.evomodel.arg.ARGReassortmentNodeCountStatistic)1