public DefaultTreeColouring sampleTreeColouring(Tree tree,ColourChangeMatrix colourChangeMatrix,MetaPopulation mp){
  DefaultTreeColouring colouring=new DefaultTreeColouring(2,tree);
  double[] N=mp.getPopulationSizes(0);
  double[] rootPartials=prune(tree,tree.getRoot(),colourChangeMatrix,N);
  double normalization=0.0;
  for (int i=0; i < rootPartials.length; i++) {
    normalization+=colourChangeMatrix.getEquilibrium(i) * rootPartials[i];
  }
  sampleInternalNodes(tree,tree.getRoot(),colourChangeMatrix);
  sampleBranchColourings(colouring,tree,tree.getRoot(),colourChangeMatrix);
  double logP=calculateLogProbabilityDensity(colouring,tree,tree.getRoot(),colourChangeMatrix,N) - Math.log(normalization);
  colouring.setLogProbabilityDensity(logP);
  return colouring;
}

public DefaultTreeColouring sampleTreeColouring ( Tree tree , ColourChangeMatrix colourChangeMatrix , MetaPopulation mp ) { DefaultTreeColouring colouring = new DefaultTreeColouring ( 2 , tree ) ; double [ ] N = mp . getPopulationSizes ( 0 ) ; double [ ] rootPartials = prune ( tree , tree . getRoot ( ) , colourChangeMatrix , N ) ; double normalization = 0.0 ; for ( int i = 0 ; i < rootPartials . length ; i ++ ) { normalization += colourChangeMatrix . getEquilibrium ( i ) * rootPartials [ i ] ; } sampleInternalNodes ( tree , tree . getRoot ( ) , colourChangeMatrix ) ; sampleBranchColourings ( colouring , tree , tree . getRoot ( ) , colourChangeMatrix ) ; double logP = calculateLogProbabilityDensity ( colouring , tree , tree . getRoot ( ) , colourChangeMatrix , N ) - Math . log ( normalization ) ; colouring . setLogProbabilityDensity ( logP ) ; return colouring ; }
colours the tree probabilistically with the given migration rates
