use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.
the class B1Statistic method getSummaryStatistic.
public double[] getSummaryStatistic(Tree tree) {
double B1 = 0.0;
int n = tree.getInternalNodeCount();
for (int i = 0; i < n; i++) {
NodeRef node = tree.getInternalNode(i);
if (!tree.isRoot(node)) {
B1 += 1.0 / getMi(tree, node);
}
}
return new double[] { B1 };
}
use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.
the class CherryStatistic method getSummaryStatistic.
public double[] getSummaryStatistic(Tree tree) {
int cherryCount = 0;
int internalNodeCount = tree.getInternalNodeCount();
for (int i = 0; i < internalNodeCount; i++) {
NodeRef node = tree.getInternalNode(i);
boolean allChildrenExternal = true;
for (int j = 0; j < tree.getChildCount(node); j++) {
if (!tree.isExternal(tree.getChild(node, j))) {
allChildrenExternal = false;
}
}
if (allChildrenExternal)
cherryCount += 1;
}
return new double[] { (double) cherryCount };
}
use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.
the class CollessIndex method getSummaryStatistic.
/**
* Assumes strictly bifurcating tree.
*/
public double[] getSummaryStatistic(Tree tree) {
double C = 0.0;
int n = tree.getInternalNodeCount();
for (int i = 0; i < n; i++) {
NodeRef node = tree.getInternalNode(i);
int r = TreeUtils.getLeafCount(tree, tree.getChild(node, 0));
int s = TreeUtils.getLeafCount(tree, tree.getChild(node, 1));
C += Math.abs(r - s);
}
n = tree.getExternalNodeCount();
C *= 2.0 / (n * (n - 3) + 2);
return new double[] { C };
}
use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.
the class ExternalBranchRates method getSummaryStatistic.
public double[] getSummaryStatistic(Tree tree) {
int externalNodeCount = tree.getExternalNodeCount();
double[] stats = new double[externalNodeCount];
int count = 0;
for (int i = 0; i < externalNodeCount; i++) {
NodeRef node = tree.getExternalNode(i);
stats[count++] = (Double) tree.getNodeAttribute(node, "rate");
}
return stats;
}
use of dr.evolution.tree.NodeRef in project beast-mcmc by beast-dev.
the class FuLiD method getSummaryStatistic.
public double[] getSummaryStatistic(Tree tree) {
double externalLength = 0.0;
double internalLength = 0.0;
int externalNodeCount = tree.getExternalNodeCount();
for (int i = 0; i < externalNodeCount; i++) {
NodeRef node = tree.getExternalNode(i);
NodeRef parent = tree.getParent(node);
externalLength += tree.getNodeHeight(parent) - tree.getNodeHeight(node);
}
int internalNodeCount = tree.getInternalNodeCount();
for (int i = 0; i < internalNodeCount; i++) {
NodeRef node = tree.getInternalNode(i);
if (!tree.isRoot(node)) {
NodeRef parent = tree.getParent(node);
internalLength += tree.getNodeHeight(parent) - tree.getNodeHeight(node);
}
}
int n = externalNodeCount;
double total = externalLength + internalLength;
// difference in expectations
double D = total - a(n) * externalLength;
// normalized
D /= Math.sqrt(u(n) * total + (v(n) * (total * total)));
return new double[] { D };
}
Aggregations