Goodman & Weare's Affine Invariant Markov chain Monte Carlo (MCMC) Ensemble sampler
Julia
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.

# AffineInvariantMCMC

AffineInvariantMCMC performs Bayesian sampling using Goodman & Weare's Affine Invariant Markov chain Monte Carlo (MCMC) Ensemble sampler. AffineInvariantMCMC is a module of MADS. Goodman & Weare's algorithm implementation in Python is called Emcee.

Reference:

Goodman, Jonathan, and Jonathan Weare. "Ensemble samplers with affine invariance." Communications in applied mathematics and computational science 5.1 (2010): 65-80.

## Example

```import AffineInvariantMCMC

numdims = 5
numwalkers = 100
thinning = 10
numsamples_perwalker = 1000
burnin = 100

const stds = exp(5 * randn(numdims))
const means = 1 + 5 * rand(numdims)
llhood = x->begin
retval = 0.
for i in 1:length(x)
retval -= .5 * ((x[i] - means[i]) / stds[i]) ^ 2
end
return retval
end
x0 = rand(numdims, numwalkers) * 10 - 5
chain, llhoodvals = AffineInvariantMCMC.sample(llhood, numwalkers, x0, burnin, 1)
chain, llhoodvals = AffineInvariantMCMC.sample(llhood, numwalkers, chain[:, :, end], numsamples_perwalker, thinning)
flatchain, flatllhoodvals = AffineInvariantMCMC.flattenmcmcarray(chain, llhoodvals)```

MADS (Model Analysis & Decision Support) is an integrated open-source high-performance computational (HPC) framework in Julia. MADS can execute a wide range of data- and model-based analyses:

• Sensitivity Analysis
• Parameter Estimation
• Model Inversion and Calibration
• Uncertainty Quantification
• Model Selection and Model Averaging
• Model Reduction and Surrogate Modeling
• Machine Learning and Blind Source Separation
• Decision Analysis and Support

MADS has been tested to perform HPC simulations on a wide-range multi-processor clusters and parallel environments (Moab, Slurm, etc.). MADS utilizes adaptive rules and techniques which allows the analyses to be performed with a minimum user input. The code provides a series of alternative algorithms to execute each type of data- and model-based analyses.

# Installation

`Pkg.add("AffineInvariantMCMC")`

## Installation behind a firewall

Julia uses git for the package management. To install Julia packages behind a firewall, add the following lines in the `.gitconfig` file in your home directory:

``````[url "https://"]
``````

or execute:

`git config --global url."https://".insteadOf git://`

Set proxies:

```export ftp_proxy=http://proxyout.<your_site>:8080
export rsync_proxy=http://proxyout.<your_site>:8080
export http_proxy=http://proxyout.<your_site>:8080
export https_proxy=http://proxyout.<your_site>:8080
export no_proxy=.<your_site>```

For example, if you are doing this at LANL, you will need to execute the following lines in your bash command-line environment:

```export ftp_proxy=http://proxyout.lanl.gov:8080
export rsync_proxy=http://proxyout.lanl.gov:8080
export http_proxy=http://proxyout.lanl.gov:8080
export https_proxy=http://proxyout.lanl.gov:8080
export no_proxy=.lanl.gov```

In Julia REPL, do the following commands:

`import Mads`

To explore getting-started instructions, execute:

`Mads.help()`

There are various examples located in the `examples` directory of the `Mads` repository.

For example, execute

`include(Mads.madsdir * "/../examples/contamination/contamination.jl")`

to perform various example analyses related to groundwater contaminant transport, or execute

`include(Mads.madsdir * "/../examples/bigdt/bigdt.jl")`

to perform Bayesian Information Gap Decision Theory (BIG-DT) analysis.