# Markov Chain Monte Carlo

 ao/mcmc MCMC - single/multiple experiments with AOs as inputs. matrix/mcmc MCMC - single/multiple experiments with matrix objects as inputs. References

The following section is dedicated to Bayesian parameter estimation techniques. Theoretical aspects are explained and some usefull examples are provided.

## A little bit of theory.

The MCMC is a statistical method that is based on random sampling from the parameter space and it is considered suitable and efficient when the parameter space is multidimensional. New samples are generated using a Markov Chain mechanism and in each jump (or step) in the parameter space, the likelihood is calculated. After a sufficient number of samples, one can investigate the shape of the likelihood surface.

## Syntax

```          % call the method
p = mcmc(out,plist);
```

Where, out is an AO or matrix object of the measured signal (output of the system).

## Parameters

The parameter list plist includes the following parameters:

• 'Model' - Input model to the algorithm.
• 'FitParams' - A cell array of evaluated parameters.
• 'input' - A matrix array (or vector of AOs) of input signals.
• 'noise' - A matrix array (or vector of AOs) of noise spectrum (PSD) used to compute the likelihood.
• 'N' - total number of samples of the chain.
• 'cov' - covariance of the gaussian jumping distribution.
• 'search' - Set to true to use bigger jumps in parameter space during annealing and cool down.
• 'frequencies' - Range of frequencies where the analysis is performed. If an array, only first and last are used.
• 'fsout' - Desired sampling frequency to resample the input time series.
• 'simplex' - Set to true to perform a simplex search to find the starting parameters of the MCMC chain.
• 'mhsample' - Set to true to perform a mhsample search. This is set to true by default. Only to be set to false by the user if we does not want to perform the mcmc search.
• 'heat' - The heat index flattening likelihood surface during annealing.
• 'x0' - The proposed initial values. A vector of values.
• 'jumps' - An array of four numbers setting the rescaling of the covariance matrix during the search phase. The first value is the one applied by default, the following thhree apply just when the chain sample is mod(10), mod(25) and mod(100) respectively.
• 'plot' - Select indexes of the parameters to be plotted. For example, if the user desires to plot all 6 chains, he should set the key to [2 3 4 5 6 7]. In the first chain the log-likelihood values are stored.
• 'debug' - Set to true to get debug information of the MCMC process.
• 'Navs' - The number of averages to use when calculating PSD and CPSD.
• 'Tc' - an array of two values setting the initial and final value for the cooling down.
• 'prior' - Mean, sigma and normalization factor for priors. Still under test.
• 'range' - Range where the parameteters are sampled. A cell array containing a vector [a b] for each parameter. The algorithm searches for the parameter between a and b.
• 'inNames' - Input names. Used for ssm models
• 'outNames' - Output names. Used for ssm models

Extra attention is needed when filling the input, noise and out fields. The objects must be organized in a arrays or matrices with a special way. The columns of a matrix are the numbers of experiments and the rows are the number of channels. In the case of LTP we have two channels. If we want to import two experiments, then for each key we specify a 2x2 AOs object or a 2x2 matrix object.

 If the user doesn't specify the value of a given parameter, the default value is used.

## Examples

There is one simple example for the use of mcmc method estimating parameters of a simple harmonic oscillator ssm model. For a more complex application (full LTP ssm model) refer to the LTPDA training 2, Topic 5.

## References

1. M Nofrarias et al, Bayesian parameter estimation in the second LISA Pathfinder mock data challenge, PHYSICAL REVIEW D 82, 122002 (2010)
2. M Nofrarias, L Ferraioli, G Congedo, Comparison of parameter estimates results in STOC Exercise 6, S2-AEI-TN-3070.