private double calculateSingleTraitLikelihood(ContrastedTraitNode contrastNode){
  SimpleTree contrastTree=new SimpleTree(contrastNode);
  double s2=0.0;
  double sssContrast=0.0;
  double slogCV=0.0;
  for (int i=0; i < contrastTree.getInternalNodeCount(); i++) {
    ContrastedTraitNode ctNode=(ContrastedTraitNode)contrastTree.getInternalNode(i);
    double contrast=ctNode.getTraitContrasts()[0];
    double cv=ctNode.getContrastVariance();
    sssContrast+=(contrast * contrast) / cv;
    slogCV+=Math.log(cv);
    if (ctNode.isRoot()) {
      slogCV+=Math.log(ctNode.getNodeVariance());
    }
  }
  double tl=0.0;
  for (int i=0; i < contrastTree.getNodeCount(); i++) {
    NodeRef node=contrastTree.getNode(i);
    if (!contrastTree.isRoot(node)) {
      tl+=contrastTree.getBranchLength(node);
    }
  }
  s2=sssContrast / contrastTree.getInternalNodeCount();
  int n=contrastTree.getInternalNodeCount() + 1;
  double logL=n * Math.log(2.0 * Math.PI * s2);
  logL+=slogCV;
  logL+=sssContrast / s2;
  logL=-logL / 2.0;
  return logL;
}

private double calculateSingleTraitLikelihood ( ContrastedTraitNode contrastNode ) { SimpleTree contrastTree = new SimpleTree ( contrastNode ) ; double s2 = 0.0 ; double sssContrast = 0.0 ; double slogCV = 0.0 ; for ( int i = 0 ; i < contrastTree . getInternalNodeCount ( ) ; i ++ ) { ContrastedTraitNode ctNode = ( ContrastedTraitNode ) contrastTree . getInternalNode ( i ) ; double contrast = ctNode . getTraitContrasts ( ) [ 0 ] ; double cv = ctNode . getContrastVariance ( ) ; sssContrast += ( contrast * contrast ) / cv ; slogCV += Math . log ( cv ) ; if ( ctNode . isRoot ( ) ) { slogCV += Math . log ( ctNode . getNodeVariance ( ) ) ; } } double tl = 0.0 ; for ( int i = 0 ; i < contrastTree . getNodeCount ( ) ; i ++ ) { NodeRef node = contrastTree . getNode ( i ) ; if ( ! contrastTree . isRoot ( node ) ) { tl += contrastTree . getBranchLength ( node ) ; } } s2 = sssContrast / contrastTree . getInternalNodeCount ( ) ; int n = contrastTree . getInternalNodeCount ( ) + 1 ; double logL = n * Math . log ( 2.0 * Math . PI * s2 ) ; logL += slogCV ; logL += sssContrast / s2 ; logL = - logL / 2.0 ; return logL ; }
calculate the likelihood of a single continuous trait on the given tree .
