statalign.base
Class Mcmc

java.lang.Object
  extended by statalign.base.thread.Stoppable
      extended by statalign.base.Mcmc

public class Mcmc
extends Stoppable

This class handles an MCMC run. The class extends Stoppable, it may be terminated/suspended in graphical mode.

Author:
miklos, novak, herman

Field Summary
 boolean burnin
          True while the MCMC is in the burn-in phase.
 McmcModule coreModel
          McmcModule containing the moves for the core components of the model, i.e. the indel parameters, substitution model parameters, alignment, topology and edge lengths.
 boolean firstHalfBurnin
          True while the MCMC is in the first half of burn-in phase.
 MCMCPars mcmcpars
          MCMC parameters including the number of burn-in steps, the total number of steps in the MCMC and the sampling rate.
 McmcStep mcmcStep
           
 ModelExtManager modelExtMan
          Manager that handles model extension plugins
 CNetwork network
           
 PostprocessManager postprocMan
          PostprocessManager that handles the postprocessing modules.
 Tree tree
          Current tree in the MCMC chain.
 
Constructor Summary
Mcmc(Tree tree, MCMCPars pars, PostprocessManager ppm, ModelExtManager modelExtMan)
           
Mcmc(Tree tree, MCMCPars pars, PostprocessManager ppm, ModelExtManager modelExtMan, int noOfProcesses, int rank, double heat)
           
 
Method Summary
 boolean acceptanceDecision(double oldLogLikelihood, double newLogLikelihood, double logProposalRatio, boolean acceptMoveIfPossible)
           
 int doMCMC()
          Starts an MCMC run.
 java.lang.String getInfoString()
          Returns a string representation describing the acceptance ratios of the current MCMC run.
 State getState()
          Returns a State object that describes the current state of the MCMC.
 boolean isParamChangeAccepted(double logProposalRatio, McmcMove m)
          This function is called by the McmcMove objects in order to determine whether the proposed moves are to be accepted.
static void main2(java.lang.String[] args)
          Code to test that various samplers are working correctly.
static void main3(java.lang.String[] args)
          Code to test that the moves are being sampled according to the correct weights (i.e. that there is not some bias arising from the choose function and/or random number generator).
static void main4(java.lang.String[] args)
           
static void main5(java.lang.String[] args)
           
 
Methods inherited from class statalign.base.thread.Stoppable
pausable, stoppable
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

network

public CNetwork network

tree

public Tree tree
Current tree in the MCMC chain.


mcmcpars

public MCMCPars mcmcpars
MCMC parameters including the number of burn-in steps, the total number of steps in the MCMC and the sampling rate.


mcmcStep

public McmcStep mcmcStep

postprocMan

public PostprocessManager postprocMan
PostprocessManager that handles the postprocessing modules.


modelExtMan

public ModelExtManager modelExtMan
Manager that handles model extension plugins


coreModel

public McmcModule coreModel
McmcModule containing the moves for the core components of the model, i.e. the indel parameters, substitution model parameters, alignment, topology and edge lengths. The coreModel also decides whether to execute MCMC moves from the ModelExtension modules.


burnin

public boolean burnin
True while the MCMC is in the burn-in phase.


firstHalfBurnin

public boolean firstHalfBurnin
True while the MCMC is in the first half of burn-in phase.

Constructor Detail

Mcmc

public Mcmc(Tree tree,
            MCMCPars pars,
            PostprocessManager ppm,
            ModelExtManager modelExtMan)

Mcmc

public Mcmc(Tree tree,
            MCMCPars pars,
            PostprocessManager ppm,
            ModelExtManager modelExtMan,
            int noOfProcesses,
            int rank,
            double heat)
Method Detail

isParamChangeAccepted

public boolean isParamChangeAccepted(double logProposalRatio,
                                     McmcMove m)
This function is called by the McmcMove objects in order to determine whether the proposed moves are to be accepted.

Parameters:
logProposalRatio - This also includes the contribution from the prior densities. It is assumed that any dependencies between the priors and other parameters will be handled inside the McmcMove objects.
Returns:
true if the move is accepted

acceptanceDecision

public boolean acceptanceDecision(double oldLogLikelihood,
                                  double newLogLikelihood,
                                  double logProposalRatio,
                                  boolean acceptMoveIfPossible)

getInfoString

public java.lang.String getInfoString()
Returns a string representation describing the acceptance ratios of the current MCMC run.

Returns:
a string describing the acceptance ratios.

getState

public State getState()
Returns a State object that describes the current state of the MCMC. This can then be passed on to other classes such as postprocessing plugins.


doMCMC

public int doMCMC()
Starts an MCMC run. If AutomateParameters.shouldAutomateProposalVariances() = true then the proposal distributions will be automatically adjusted during the burnin. If AutomateParameters.shouldAutomateNumberOfSamples() = true or AutomateParameters.shouldAutomateStepRate() = true or AutomateParameters.shouldAutomateBurnin() = true then these parameters will be adjusted automatically, although this approach may affect the theoretical convergence properties of the MCMC chain, so this type of automation should be regarded more as a quick way of getting some initial results without tweaking the parameters. This function also calls the appropriate functions of the PostpocessManager postprocMan to trigger data transfer to postprocessing modules when necessary


main5

public static void main5(java.lang.String[] args)

main4

public static void main4(java.lang.String[] args)

main3

public static void main3(java.lang.String[] args)
Code to test that the moves are being sampled according to the correct weights (i.e. that there is not some bias arising from the choose function and/or random number generator).


main2

public static void main2(java.lang.String[] args)
Code to test that various samplers are working correctly.