SPINspiral
SPINspiral is a parameter-estimation code for gravitational-wave signals detected by LIGO/Virgo
Functions
src/SPINspiral_mcmc.c File Reference

(SPINspiral version 0.5.1, revision 275)

Contains MCMC routines. More...

#include <SPINspiral.h>
Include dependency graph for SPINspiral_mcmc.c:

Functions

void MCMC (struct runPar run, struct interferometer *ifo[])
 MCMC routine - forms the MCMC core of the program.
void par2arr (struct parSet par, double **param, struct MCMCvariables mcmc)
 Put the MCMC parameters in an array.
void arr2par (double **param, struct parSet *par, struct MCMCvariables mcmc)
 Get the MCMC parameters out of their array.
double prior (double *par, int p, struct MCMCvariables mcmc)
 Compute the prior for the given parameter set.
double sigmaPeriodicBoundaries (double sigma, int p, struct MCMCvariables mcmc)
 Bring the adaptation sigma between its periodic boundaries.
void correlatedMCMCupdate (struct interferometer *ifo[], struct parSet *state, struct MCMCvariables *mcmc, struct runPar run)
 Do a correlated block MCMC update.
void uncorrelatedMCMCsingleUpdate (struct interferometer *ifo[], struct parSet *state, struct MCMCvariables *mcmc, struct runPar run)
 Do an uncorrelated, per-parameter MCMC update.
void uncorrelatedMCMCblockUpdate (struct interferometer *ifo[], struct parSet *state, struct MCMCvariables *mcmc, struct runPar run)
 Do an uncorrelated block update.
void writeMCMCheader (struct interferometer *ifo[], struct MCMCvariables mcmc, struct runPar run)
 Write MCMC header to screen and file.
void writeMCMCoutput (struct MCMCvariables mcmc, struct interferometer *ifo[])
 Write an MCMC iteration as an output line to screen and/or file.
void allocateMCMCvariables (struct MCMCvariables *mcmc)
 Allocate memory for the MCMCvariables struct.
void freeMCMCvariables (struct MCMCvariables *mcmc)
 Deallocate memory for the MCMCvariables struct.
void updateCovarianceMatrix (struct MCMCvariables *mcmc)
 Calculate the new covariance matrix and determine whether the new matrix should be accepted.
void CholeskyDecompose (double **A, struct MCMCvariables *mcmc)
 Compute Cholesky decomposition matrix.
double annealTemperature (double temp0, int nburn, int nburn0, int iIter)
 Annealing: set the temperature according to the iteration number and burnin.
void swapChains (struct MCMCvariables *mcmc)
 Parallel tempering: Swap states between two chains.
void writeChainInfo (struct MCMCvariables mcmc)
 Parallel tempering: Print chain and swap info to screen.
void startMCMCOffset (struct parSet *par, struct MCMCvariables *mcmc, struct interferometer *ifo[], struct runPar run)
 Choose and print offset starting values for the Markov chain.
void setTemperatureLadder (struct MCMCvariables *mcmc)
 Set up the temperature ladder for parallel tempering.
void setTemperatureLadderOld (struct MCMCvariables *mcmc)
 Set up the temperature ladder for parallel tempering - old routine.

Detailed Description

Contains MCMC routines.


Function Documentation

void MCMC ( struct runPar  run,
struct interferometer ifo[] 
)

MCMC routine - forms the MCMC core of the program.

Initialise and build a Markov chain

References MCMCvariables::acceptPrior, MCMCvariables::acceptRateTarget, MCMCvariables::adaptiveMCMC, MCMCvariables::adaptScale, MCMCvariables::adaptSigma, allocateMCMCvariables(), allocParset(), MCMCvariables::annealNburn, MCMCvariables::annealNburn0, MCMCvariables::annealTemp0, annealTemperature(), arr2par(), MCMCvariables::baseTime, MCMCvariables::beVerbose, MCMCvariables::blockFrac, MCMCvariables::chTemp, copyRun2MCMC(), correlatedMCMCupdate(), MCMCvariables::correlatedUpdates, MCMCvariables::corrFrac, MCMCvariables::corrUpdate, MCMCvariables::covar, MCMCvariables::decreaseSigma, MCMCvariables::dlogL, MCMCvariables::fouts, freeMCMCvariables(), freeParset(), getInjectionParameters(), getStartParameters(), MCMCvariables::hist, MCMCvariables::iHist, MCMCvariables::iIter, MCMCvariables::increaseSigma, MCMCvariables::injectionWaveform, MCMCvariables::injectSignal, MCMCvariables::injID, MCMCvariables::injParUse, MCMCvariables::injParVal, MCMCvariables::injRevID, MCMCvariables::iTemp, localPar(), MCMCvariables::logL, max, MCMCvariables::maxdlogL, MCMCvariables::maxLparam, MCMCvariables::mcmcWaveform, MCMCvariables::minlogL, MCMCvariables::nCorr, netLogLikelihood(), MCMCvariables::networkSize, MCMCvariables::nInjectPar, MCMCvariables::nIter, MCMCvariables::nlogL, MCMCvariables::nMCMCpar, MCMCvariables::nParam, MCMCvariables::nParFit, MCMCvariables::nTemps, runPar::outputPath, par2arr(), MCMCvariables::parallelTempering, MCMCvariables::param, MCMCvariables::parBestVal, MCMCvariables::parFix, MCMCvariables::parID, MCMCvariables::parSigma, MCMCvariables::prParTempInfo, MCMCvariables::ran, MCMCvariables::saveHotChains, MCMCvariables::seed, setTemperatureLadderOld(), sigmaPeriodicBoundaries(), startMCMCOffset(), swapChains(), MCMCvariables::tempAmpl, MCMCvariables::tempLadder, MCMCvariables::tempOverlap, tpi, uncorrelatedMCMCblockUpdate(), uncorrelatedMCMCsingleUpdate(), updateCovarianceMatrix(), writeChainInfo(), writeMCMCheader(), and writeMCMCoutput().

Referenced by main().

void par2arr ( struct parSet  par,
double **  param,
struct MCMCvariables  mcmc 
)
void arr2par ( double **  param,
struct parSet par,
struct MCMCvariables  mcmc 
)
double prior ( double *  par,
int  p,
struct MCMCvariables  mcmc 
)

Compute the prior for the given parameter set.

Contains boundary conditions and prior information for the MCMC. Try to avoid returning 0, to increase jump sizes

References mtpi, pi, MCMCvariables::priorBoundLow, MCMCvariables::priorBoundUp, MCMCvariables::priorType, and tpi.

Referenced by correlatedMCMCupdate(), startMCMCOffset(), uncorrelatedMCMCblockUpdate(), and uncorrelatedMCMCsingleUpdate().

double sigmaPeriodicBoundaries ( double  sigma,
int  p,
struct MCMCvariables  mcmc 
)

Bring the adaptation sigma between its periodic boundaries.

References min, pi, MCMCvariables::priorType, and tpi.

Referenced by MCMC(), and uncorrelatedMCMCsingleUpdate().

void correlatedMCMCupdate ( struct interferometer ifo[],
struct parSet state,
struct MCMCvariables mcmc,
struct runPar  run 
)

Do a correlated block MCMC update.

Do an update for all non-fixed MCMC parameters. Use the covariance matrix to take into account correlations. The covariance matrix has been constructed from previous iterations. Use adaptation to scale the whole matrix. Some experiments with larger jumps using the 'hotter' covariance matrix.

References MCMCvariables::accepted, MCMCvariables::acceptPrior, MCMCvariables::adaptiveMCMC, MCMCvariables::adaptSigmaOut, arr2par(), MCMCvariables::chTemp, MCMCvariables::corrSig, MCMCvariables::covar, MCMCvariables::decreaseSigma, MCMCvariables::increaseSigma, MCMCvariables::iTemp, localPar(), MCMCvariables::logL, max, MCMCvariables::mcmcWaveform, min, MCMCvariables::minlogL, netLogLikelihood(), MCMCvariables::networkSize, MCMCvariables::nlogL, MCMCvariables::nMCMCpar, MCMCvariables::nParam, par2arr(), MCMCvariables::param, MCMCvariables::parFix, prior(), and MCMCvariables::ran.

Referenced by MCMC().

void uncorrelatedMCMCsingleUpdate ( struct interferometer ifo[],
struct parSet state,
struct MCMCvariables mcmc,
struct runPar  run 
)
void uncorrelatedMCMCblockUpdate ( struct interferometer ifo[],
struct parSet state,
struct MCMCvariables mcmc,
struct runPar  run 
)

Do an uncorrelated block update.

Do an update for all non-fixed MCMC parameters in the current T chain. Propose a jump and decide whether to accept or not for all parameters at once. No adaptation here, some experimenting with larger jumps every now and then.

References MCMCvariables::accepted, MCMCvariables::acceptPrior, MCMCvariables::adaptSigma, arr2par(), MCMCvariables::chTemp, MCMCvariables::iTemp, localPar(), MCMCvariables::logL, max, MCMCvariables::mcmcWaveform, min, MCMCvariables::minlogL, netLogLikelihood(), MCMCvariables::networkSize, MCMCvariables::nlogL, MCMCvariables::nMCMCpar, MCMCvariables::nParam, par2arr(), MCMCvariables::param, MCMCvariables::parFix, prior(), and MCMCvariables::ran.

Referenced by MCMC().

void writeMCMCheader ( struct interferometer ifo[],
struct MCMCvariables  mcmc,
struct runPar  run 
)
void writeMCMCoutput ( struct MCMCvariables  mcmc,
struct interferometer ifo[] 
)
void allocateMCMCvariables ( struct MCMCvariables mcmc)
void freeMCMCvariables ( struct MCMCvariables mcmc)
void updateCovarianceMatrix ( struct MCMCvariables mcmc)

Calculate the new covariance matrix and determine whether the new matrix should be accepted.

Compute the new covariance matrix for the current T chain. Determine by the 'improvement' of the new matrix whether it should be accepted.

References MCMCvariables::acceptElems, CholeskyDecompose(), MCMCvariables::corrUpdate, MCMCvariables::covar, MCMCvariables::hist, MCMCvariables::histDev, MCMCvariables::histMean, MCMCvariables::iIter, MCMCvariables::iTemp, MCMCvariables::matAccFr, max, MCMCvariables::nCorr, MCMCvariables::nMCMCpar, MCMCvariables::nParFit, MCMCvariables::nTemps, MCMCvariables::parFix, and MCMCvariables::prMatrixInfo.

Referenced by MCMC().

void CholeskyDecompose ( double **  A,
struct MCMCvariables mcmc 
)

Compute Cholesky decomposition matrix.

Performs Cholesky decompositon of matrix A and returns result in the same matrix - adapted from PJG Fortran function If matrix is not positive definite, return zeroes

References MCMCvariables::nMCMCpar, and MCMCvariables::parFix.

Referenced by updateCovarianceMatrix().

double annealTemperature ( double  temp0,
int  nburn,
int  nburn0,
int  iIter 
)

Annealing: set the temperature according to the iteration number and burnin.

References max, and min.

Referenced by MCMC().

void swapChains ( struct MCMCvariables mcmc)
void writeChainInfo ( struct MCMCvariables  mcmc)
void startMCMCOffset ( struct parSet par,
struct MCMCvariables mcmc,
struct interferometer ifo[],
struct runPar  run 
)

Choose and print offset starting values for the Markov chain.

Set MCMC parameters to either the best-guess values or the injection values (where possible). Then, depending on the detailed per-parameter settings, add a random offset from this value. Require a good value for logL (determined by mcmc->minlogL) in order to accept the proposed starting values, unless MCMC parameters do not fully match the injection parameters. This happens independently of whether parameters are fixed or not! Finally, print the selected starting values to screen.

References MCMCvariables::acceptPrior, arr2par(), MCMCvariables::beVerbose, MCMCvariables::injectionWaveform, MCMCvariables::injectSignal, MCMCvariables::injID, MCMCvariables::injParUse, MCMCvariables::injParVal, MCMCvariables::injRevID, MCMCvariables::iTemp, localPar(), MCMCvariables::logL, max, MCMCvariables::mcmcWaveform, netLogLikelihood(), MCMCvariables::networkSize, MCMCvariables::nMCMCpar, MCMCvariables::nParam, MCMCvariables::offsetMCMC, MCMCvariables::offsetX, MCMCvariables::parAbrev, MCMCvariables::param, MCMCvariables::parBestVal, MCMCvariables::parID, MCMCvariables::parSigma, MCMCvariables::parStartMCMC, prior(), MCMCvariables::priorBoundLow, MCMCvariables::priorBoundUp, MCMCvariables::ran, and MCMCvariables::thinScreenOutput.

Referenced by MCMC().

void setTemperatureLadder ( struct MCMCvariables mcmc)
void setTemperatureLadderOld ( struct MCMCvariables mcmc)
 All Data Structures Files Functions Variables Defines