Exemplo n.º 1
0
double Tree::lnPriorRatio(double nh, double oh) {

	nh = nh * treeScale;
	oh = oh * treeScale;

	if (treeTimePrior == 1) {
	}
	else if (treeTimePrior == 2) {
		double diff = modelPtr->getActiveSpeciation()->getNetDiversification();
		double nator = (-(diff) * nh);
		double dator = (-(diff) * oh);
		return nator - dator;
	} else {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		double rel = s->getRelativeDeath(); // dr / br

		double zn = log(1 - (rel) * exp(-(diff) * nh));
		double nator = -2 * zn + (-(diff) * nh);

		double zd = log(1 - (rel) * exp(-(diff) * oh));
		double dator = -2 * zd + (-(diff) * oh);

		return nator - dator;
	}
	return 0.0;
}
Exemplo n.º 2
0
double Treescale::getLnTreeProb(Tree *t) {
	
	if(treeTimePrior == 1)
		return 0.0;
	else if(treeTimePrior == 2 || treeTimePrior == 3){
		
		return t->getTreeCBDNodePriorProb();
	}
	else if(treeTimePrior == 4 || treeTimePrior == 5){
		Speciation *s = modelPtr->getActiveSpeciation();
		double nps = t->getTreeBDSSTreeNodePriorProb(s->getNetDiversification(), 
													 s->getRelativeDeath(), s->getBDSSFossilSampRatePsi(), 
													 s->getBDSSSppSampRateRho(), treeOriginTime);
		return nps;
	}
	else if(treeTimePrior == 6){
		Speciation *s = modelPtr->getActiveSpeciation();
		s->setAllBDFossParams();
		double nps = t->getTreeCalBDSSTreeNodePriorProb(s->getBDSSSpeciationRateLambda(), 
														s->getBDSSExtinctionRateMu(), 
														s->getBDSSFossilSampRatePsi(), 
														s->getBDSSSppSampRateRho());
		return nps;
	}
	else if(treeTimePrior == 7){
		Speciation *s = modelPtr->getActiveSpeciation();
		s->setAllBDFossParams();
		double nps = t->getTreeAncCalBDSSTreeNodePriorProb(s->getBDSSSpeciationRateLambda(), 
														s->getBDSSExtinctionRateMu(), 
														s->getBDSSFossilSampRatePsi(), 
														s->getBDSSSppSampRateRho());
		return nps;
	}
	return 0.0;
}
Exemplo n.º 3
0
double Tree::getTreeSpeciationProbability() {
	if (treeTimePrior == 1)
		return 0.0;
	else if (treeTimePrior == 2) {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification();
		double c1 = (numTaxa - 1) * log(diff);
		double nps = getTreeCBDNodePriorProb(diff, 0.0);
		return c1 + nps;
	} else {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		double rel = s->getRelativeDeath();
		double lnC = 0.0;
		double c1 = ((numTaxa - 1) * log(diff)) + (numTaxa * log(1 - rel));
		double nps = getTreeCBDNodePriorProb(diff, rel);
		return lnC + c1 + nps;
	}
	return 0.0;
}
Exemplo n.º 4
0
double Tree::getTreeCBDNodePriorProb() {

	double nprb = 0.0;
	if (treeTimePrior == 1)
		return 0.0;
	else if (treeTimePrior == 2) {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		for (int i = 0; i < numNodes; i++) {
			Node *p = &nodes[i];
			if (p->getIsLeaf() == false) {
				double nh = p->getNodeDepth() * treeScale;
				double l = (-(diff) * nh);
				if (p == root) {
					l += (-(diff) * nh);
				}
				nprb += l;
			}
		}
		return nprb;
	} else {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		double rel = s->getRelativeDeath(); // dr / br
		for (int i = 0; i < numNodes; i++) {
			Node *p = &nodes[i];
			if (p->getIsLeaf() == false) {
				double nh = p->getNodeDepth() * treeScale;
				double zn = log(1 - (rel) * exp(-(diff) * nh));
				double l = -2 * zn + (-(diff) * nh);
				if (p == root) {
					l += (-(diff) * nh) - zn;
				}
				nprb += l;
			}
		}
		return nprb;
	}
	return 0.0;
}