protected double calculateLogLikelihood(){
  NodeRef root=treeModel.getRoot();
  if (rootPartials == null) {
    rootPartials=new double[patternCount * stateCount];
  }
  if (patternLogLikelihoods == null) {
    patternLogLikelihoods=new double[patternCount];
  }
  if (!integrateAcrossCategories) {
    if (siteCategories == null) {
      siteCategories=new int[patternCount];
    }
    for (int i=0; i < patternCount; i++) {
      siteCategories[i]=siteModel.getCategoryOfSite(i);
    }
  }
  double p=proportionParameter.getParameterValue(0);
  double lambda=Math.log(2) / lambdaParameter.getParameterValue(0);
  updateRates=true;
  updateAllNodes();
  if (updateRates) {
    if (nodeTimes == null) {
      nodeTimes=new double[treeModel.getNodeCount()];
    }
    calculateNodeRates(treeModel,root,1.0,p,lambda);
  }
  traverse(treeModel,root);
  updateRates=false;
  for (int i=0; i < nodeCount; i++) {
    updateNode[i]=false;
  }
  double logL=0.0;
  for (int i=0; i < patternCount; i++) {
    logL+=patternLogLikelihoods[i] * patternWeights[i];
  }
  if (Double.isNaN(logL)) {
    throw new RuntimeException("Likelihood NaN");
  }
  return logL;
}

protected double calculateLogLikelihood ( ) { NodeRef root = treeModel . getRoot ( ) ; if ( rootPartials == null ) { rootPartials = new double [ patternCount * stateCount ] ; } if ( patternLogLikelihoods == null ) { patternLogLikelihoods = new double [ patternCount ] ; } if ( ! integrateAcrossCategories ) { if ( siteCategories == null ) { siteCategories = new int [ patternCount ] ; } for ( int i = 0 ; i < patternCount ; i ++ ) { siteCategories [ i ] = siteModel . getCategoryOfSite ( i ) ; } } double p = proportionParameter . getParameterValue ( 0 ) ; double lambda = Math . log ( 2 ) / lambdaParameter . getParameterValue ( 0 ) ; updateRates = true ; updateAllNodes ( ) ; if ( updateRates ) { if ( nodeTimes == null ) { nodeTimes = new double [ treeModel . getNodeCount ( ) ] ; } calculateNodeRates ( treeModel , root , 1.0 , p , lambda ) ; } traverse ( treeModel , root ) ; updateRates = false ; for ( int i = 0 ; i < nodeCount ; i ++ ) { updateNode [ i ] = false ; } double logL = 0.0 ; for ( int i = 0 ; i < patternCount ; i ++ ) { logL += patternLogLikelihoods [ i ] * patternWeights [ i ] ; } if ( Double . isNaN ( logL ) ) { throw new RuntimeException ( "Likelihood NaN" ) ; } return logL ; }
calculate the log likelihood of the current state .
