{"id":16073331,"url":"https://github.com/larsgeb/mpi_mc3","last_synced_at":"2026-06-21T01:03:17.997Z","repository":{"id":106140702,"uuid":"146038712","full_name":"larsgeb/MPI_MC3","owner":"larsgeb","description":"MC3 RWMH using MPI.","archived":false,"fork":false,"pushed_at":"2018-08-24T21:24:04.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T21:19:31.127Z","etag":null,"topics":["markov-chain-monte-carlo","mcmc","mcmcmc","parallel-mcmc","random-walk","replica-exchange"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larsgeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-24T20:48:54.000Z","updated_at":"2018-08-24T21:24:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"49f82953-fbb0-481c-bb07-b96f6b09d410","html_url":"https://github.com/larsgeb/MPI_MC3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgeb%2FMPI_MC3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgeb%2FMPI_MC3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgeb%2FMPI_MC3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsgeb%2FMPI_MC3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larsgeb","download_url":"https://codeload.github.com/larsgeb/MPI_MC3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247321387,"owners_count":20919983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markov-chain-monte-carlo","mcmc","mcmcmc","parallel-mcmc","random-walk","replica-exchange"],"created_at":"2024-10-09T08:06:44.816Z","updated_at":"2026-06-21T01:03:12.967Z","avatar_url":"https://github.com/larsgeb.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPI_MC3\nMetropolis coupled Markov chain Monte Carlo sampler using the Random Walk \nMetropolis-Hastings algorithm using MPI implementation.\n\nMC³ offers a way to optimize sampling from related distributions by exchanging \nreplicas. This helps amongst others to explore local minima.\n\nSampling in this implementation is MPI parallel. However, the coupling does require \nprocesses (samplers) to be synchronised. This could be reduced to synchronisation every\nn-th sample.\n\n## Compilation and running\n\nThe program can be compiled with either ``mpic++`` or CMake. Running is done \nthrough ``mpi_exec -n 2`` (only two processes for now).\n\n## Example with double potential well\n\n**without coupling**\n\nWe use the double potential well target function (the idea is from \n[Darren Wilkinson's research blog](https://darrenjw.wordpress.com/2013/09/29/parallel-tempering-and-metropolis-coupled-mcmc/)). \nWe sample the distributions gamma = 1 and gamma = 30.\n\nThe sampler settings are the following for uncoupled sampling:\n\n    // Settings for the sampler\n    #define STARTING_SAMPLE -1.0\n    #define LOWLIMU 0.0\n    #define UPPLIMU 1.0\n    #define COUPLING false\n    #define COUPLING_INTERVAL 100\n    #define PROPOSALS 100000\n    #define WALKSTEP0 0.5\n    #define WALKSTEP1 0.05\n    \nBecause the distribution with gamma = 30 has such strong misfit gradients, a much \nsmaller RWMH stepsize is needed.\n\nOne resulting multidimensional chain (Sampling is performed at the same time, \nhence multidimensional. They are not yet coupled!) is given in the following figure, \nwhere black lines indicate the true pdf, and the histograms the Markov Chains:\n\n![samples without replica exchange](./examples/without.png)\n\nAs can be seen, the low barrier (top) distribution is well sampled. On the bottom, \nthe distribution with the strong barrier, is only sampled near its starting point.\n\n**with coupling**\n    \nNow, enabling Metropolis coupling (but effectively halving the RWMH steps by allocating space for MCMCMC steps):\n\n    // Settings for the sampler\n    #define STARTING_SAMPLE -1.0\n    #define LOWLIMU 0.0\n    #define UPPLIMU 1.0\n    #define COUPLING true                \u003c---- this changed\n    #define COUPLING_INTERVAL 100\n    #define PROPOSALS 100000\n    #define WALKSTEP0 0.5\n    #define WALKSTEP1 0.05\n    \nThis gives the following result:\n\n![samples without replica exchange](./examples/with.png)\n\nWhere both minima of the lower distribution are well sampled.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsgeb%2Fmpi_mc3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarsgeb%2Fmpi_mc3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsgeb%2Fmpi_mc3/lists"}