mcmc clib

a c program for simplified manifold MALA sampling of ODE model parameters


Project maintained by a-kramer (mail) Hosted on GitHub Pages — Theme by mattgraham

The bundle contains a user manual (pdf) and a mathematical documentation (pdf).

This software's characteristics:

Installation Instructions

install the following dependencies (libraries)

External library dependencies
    For ODE: 
        Sundials 2.4.0 or later
    For MCMC:
        GSL 1.15 or later
        CBLAS

For VFGEN:
    CLN 1.3.2 or later
    GiNaC 1.6.2 or later
    mini XML 2.6 or later
If you only have a user account without root priviliges, then ask your system administrator for help.

For example, on ubuntu, you can install the following packages using apt-get or the ubuntu software center:

libmxml-dev 
libmxml1 
libatlas-base-dev 
libatlas3gf-base
libginac-dev 
libcln-dev 
libsundials-serial-dev 
libsundials-cvode1
libsundials-cvodes2
libatlas-dev
libgsl0-dev

This should work for all ubuntu derivatives and ubuntu based distributions like linux Mint and elementary OS.

Here are some further hints for Installation on Gentoo linux, Arch linux and OpenSUSE.

In principle, it is possible to compile the sources on a windows system. No binary release has been build yet.

Next, inspect the Makefile. You can use it as a starting point for your own project. The bundled Makefile builds the vfgen executable as well as the sampler and a shared library for the model.

Afterwards, use the Makefile by typing

make -B

Note that the option -B will compile the sampler, vfgen, the provided example model (to a shared library); even if the binaries appear up to date. This option is not necessary after this one initial run (if it is successful).

To check whether the program works, execute ./run_test.sh in the shell. If it terminates immediately, then check the file ending in err. Otherwise the test run will proceed to reproduce the sampling we used in the application note. The results can be found in sample/${modelname}-${date}.double.

Usage

./ode_smmala -l ./model.so -c ./data.cfg -b \
             -o sample.double -s $((3*10**4)) > logfile.out

-b 
      switches output mode to binary, otherwise text mode (printf)
      Burn-In Sample will always be printed to stdout

-c data.cfg
      configuration (data, reference data, inputs, output function, 
      prior, etc.)

-l model.so
      shared library file

-s N
      sample size

-h 
      prints help

The configuration file includes the measurement time specifications, the data, the standard deviation of observations and the hyperparameters μ and Σ^{-1} of the Gaussian prior. Optionally some of the sampling parameters can be set there for convenience. Edit the bundled configuration file to suit your needs. If your data is not relative, delete the reference data block; the program will handle this case correctly.

The following Parameters can be set in the configuration file:

Property Setting
sample size sample_size=[integer]
step size step_size=[double]
target acceptance acceptance=[0, 1]
sample file name output=[string]
initial condition time t0=[double]

These definitions should not have spaces before the '=' sign since everything before '=' is checked for matches with option names (i.e.
« t0 »=0.0; is not the same as «t0»=0.0; ).

Hints

it might be helpful to specify the sample size like this in bash:

   -s $((2**14))
   -s $((10**6))

because 1e6 or 1E6 will not work. (the sample size is an integer).

Output of parameters sample {p} will have the following structure (in binary and text mode; though, in binary mode there are no newlines):

sampling is done in logarithmic space, so use exp(p[i]) if you want to simulate trajectories

columns: parameters and log-posterior rows: Markov Chain members (i.e. the sample members)

   Line 
   L1   p[0] p[1] p[2] ... p[n-1] log-Posterior {\n}
   L2   p[0] p[1] p[2] ... p[n-1] log-Posterior {\n}
   L3   p[0] p[1] p[2] ... p[n-1] log-Posterior {\n}
   L4   p[0] p[1] p[2] ... p[n-1] log-Posterior {\n}
   ...
   L{sample_size}      ...

you can load the binary sample using an fread type function.

e.g. in octave: [VAL, COUNT] = fread (FID, SIZE, PRECISION,SKIP, ARCH)

so:

     FID=fopen("MySample.double","r");
     sample=fread(FID,[n+1,sample_size],"double");
     fclose(FID);

should work fine. In fact, the sources include octave scripts that read and process the sample.