We try to share our codes on GitHub as much as possible. Check out the GAIA repository here: Below is a description of some elements of this repository. You will also find some other things, such as links to external codes we are typically using or datasets.

Training images

A set of training images is provided on our repository.

If you are wondering where you can find a 3D training image for alluvial environments, check out the aquifers analogs that we published. The data are here and the paper describing it is here.

MPS using QuickSampling

The QuickSampling MPS code is freely available for Linux / macOS / Windows 10 and is usable form Matlab / Python3 and R on the dedicated GitHub repository. This is our latest MPS implementation, more recent than Direct Sampling, and often faster.

MPS using Direct Sampling

The Direct Sampling code comes in many versions. Some are properly compiled codes, other only Matlab scripts:

Compiled libraries:

Two separate implementations of the Direct Sampling code exist. Both have examples and a proper documentation, but unfortunately cannot be shared on repositories:

  1. The DS implementation of the University of Lausanne can be requested by sending an email to In this version, most of the features presented in the literature are present.
  2. The implementation of the University of Neuchatel (called DeeSse) can be obtained by contacting Prof. Philippe Renard (

Both codes are only available for academic, non-commercial purposes, and to the discretion of the University of Neuchatel who owns the intellectual property of the algorithm.

There is an excellent and freely available MPS library written by Thomas Hansen from the Niels Bohr Institute, available here .

Matlab versions:

A simple version written in Matlab, with a fixed template, is available for demonstration and teaching purposes. IT SHOULD NOT BE USED FOR BENCHMARKING OR FOR COMPARISON WITH OTHER METHODS BECAUSE IT IS EXTREMELY BASIC AND SLOW.

An advanced version of the Matlab Direct Sampling code for is also available. It considers variable lag vectors and flexible data events, and seems to have issues with conditioning (I will fix it when I find the time). THIS ONE SHOULD ALSO NOT BE USED FOR BENCHMARKING OR FOR COMPARISON WITH OTHER METHODS BECAUSE EVEN SLOWER THAN THE SIMPLE VERSION. MOREOVER IT HAS PROBLEMS WITH CONDITIONING.

Another version of the Direct Sampling is the bunch-pasting strategy of Rezaee et al (2013), for which there is also a Matlab code. AGAIN, IT SHOULD NOT BE USED FOR BENCHMARKING.

Note that there may be other versions out there that I am not aware of!

MPS using Graph-cuts based simulation

We recently developed a graph-cuts based MPS simulation algorithm which is an improvement over Image Quilting. The Matlab code can be found here.

MPS using Image Quilting

The Matlab code for MPS simulation by Image Quilting is available here. Note that it uses some of our Matlab utilities.

General purpose utilities

Here is a set of small Matlab geostatistical tools that you can download and use freely. A basic documentation is also included. Thanks for sending feedback!

MPS-related utilities

Our patterns validation code (Windows executable and Fortran code) allows finding out if a training image is compatible with a given data pointset.

Before writing your own code for geostatistical simulation or estimation, check out some nice existing free ones such as SGeMS and mGstat.

Inverse modeling

If you are working on spatial inverse models with MPS and are looking for a benchmark forward flow and transport model, you can use one of the case studies we developed in our paper on parallel tempering. It uses the MAFLOT flow and transport simulation code for the forward problem ( The forward problem is very fast, which is needed when investing inverse approaches.

The code for the tempering approach in Laloy et al (2016) is available here (read the instructions in the file run_ptsgr.m).