MCMC instructions

Compiling and running
When L-Galaxies is run in MCMC mode, the code will explore likelihood space in an attempt to find the best-fit values for a given (sub)set of model parameters, subject to a given set of observational constraints. To compile L-Galaxies in MCMC mode, set the compiler flag DMCMC in the Makefile options, or set "include Makefile_options/Makefile_options_MCMC" in Makefile to use a set of compatible Makefile options. It is advised to compile and run MCMC in parallel mode, using OpenMPI.



Files and Parameters
There are several additional parameters that need to be passed to L-Galaxies in MCMC mode. An example parameter file for L-Galaxies 2020 is provided in /input/MCMC_inputs/input_mcmc_LGals2020_MR_W1_PLANCK.par. Comparing this file with a non-MCMC parameter file in /input, you may notice two things: the parameters "FirstFile" and "LastFile" are not needed, and there is a new category "Variables needed for the MCMC". Let's go through this new category. First, some files and parameters that tell the code where to look for inputs:



MCMC settings
Next up are settings for the actual MCMC:



Merger tree sampling
Finally, the last group of parameters determine the sample of subhalo merger trees that are used by L-Galaxies:



Outputs
While running the code in MCMC mode, L-Galaxies will output the step in the chain, the current set of parameters and the likelihood due to the individual selected observational constraints to screen. The total minus log-likelihood and log values of the current parameter set will be output to the output directory in senna*.txt files (preceded by the chain weight, which is typically 1), one file per thread (and one line per step in the chain). It will also output explicitly when a new set of parameters is accepted. By reading all likelihoods and parameters from the output chains (after the burn-in phase), you can not only find the best-fit set of parameters (those with the lowest minus log-likelihood), but also get an idea of what the total likelihood landscape looks like.