diff --git a/mex/build/logMHMCMCposterior.am b/mex/build/logMHMCMCposterior.am
new file mode 100644
index 0000000000000000000000000000000000000000..b20be837366968afc633a9fd435b20be996a8860
--- /dev/null
+++ b/mex/build/logMHMCMCposterior.am
@@ -0,0 +1,62 @@
+vpath %.cc $(top_srcdir)/../../sources/estimation $(top_srcdir)/../../sources/estimation/libmat $(top_srcdir)/../../sources/estimation/utils
+vpath %.hh $(top_srcdir)/../../sources/estimation $(top_srcdir)/../../sources/estimation/libmat
+
+CPPFLAGS += -I$(top_srcdir)/../../sources/estimation/libmat -I$(top_srcdir)/../../sources/estimation/utils $(BOOST_CPPFLAGS)
+LDFLAGS += $(BOOST_LDFLAGS)
+
+noinst_PROGRAMS = logMHMCMCposterior
+
+logMHMCMCposterior_LDADD = $(LIBADD_DLOPEN)
+
+MAT_SRCS = \
+	Matrix.hh \
+	Matrix.cc \
+	Vector.hh \
+	Vector.cc \
+	BlasBindings.hh \
+	DiscLyapFast.hh \
+	GeneralizedSchurDecomposition.cc \
+	GeneralizedSchurDecomposition.hh \
+	LapackBindings.hh \
+	LUSolver.cc \
+	LUSolver.hh \
+	QRDecomposition.cc \
+	QRDecomposition.hh \
+	VDVEigDecomposition.cc \
+	VDVEigDecomposition.hh
+
+nodist_logMHMCMCposterior_SOURCES = \
+	$(MAT_SRCS) \
+	DecisionRules.cc \
+	DecisionRules.hh \
+	DetrendData.cc \
+	DetrendData.hh \
+	EstimatedParameter.cc \
+	EstimatedParameter.hh \
+	EstimatedParametersDescription.cc \
+	EstimatedParametersDescription.hh \
+	EstimationSubsample.cc \
+	EstimationSubsample.hh \
+	InitializeKalmanFilter.cc \
+	InitializeKalmanFilter.hh \
+	KalmanFilter.cc \
+	KalmanFilter.hh \
+	LogLikelihoodSubSample.cc \
+	LogLikelihoodSubSample.hh \
+	LogLikelihoodMain.hh \
+	LogLikelihoodMain.cc \
+	LogPosteriorDensity.cc \
+	LogPosteriorDensity.hh \
+	LogPriorDensity.cc \
+	LogPriorDensity.hh \
+	ModelSolution.cc \
+	ModelSolution.hh \
+	Prior.cc \
+	Prior.hh \
+	RandomWalkMetropolisHastings.cc \
+	RandomWalkMetropolisHastings.hh \
+	RandSampler.cc \
+	RandSampler.hh \
+	dynamic_dll.cc \
+	dynamic_dll.hh \
+	logMHMCMCposterior.cc
diff --git a/mex/build/matlab/Makefile.am b/mex/build/matlab/Makefile.am
index a06359d3d9fbcd73a76c71005530c13623bfc31c..bfb2c60940149a287831c30331bcc795bd0755f1 100644
--- a/mex/build/matlab/Makefile.am
+++ b/mex/build/matlab/Makefile.am
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I ../../../m4
 
 # libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
 if DO_SOMETHING
-SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_ logposterior
+SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_ logposterior logMHMCMCposterior
 if HAVE_GSL
 SUBDIRS += swz
 endif
diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac
index 1de917537ecb955f0e08365860cf93a1cdfa9bc0..2545b6ce2055dd2a3d318755cfbdc7124e025a60 100644
--- a/mex/build/matlab/configure.ac
+++ b/mex/build/matlab/configure.ac
@@ -118,6 +118,7 @@ AC_CONFIG_FILES([Makefile
                  k_order_perturbation/Makefile
                  dynare_simul_/Makefile
                  swz/Makefile
-                 logposterior/Makefile])
+                 logposterior/Makefile
+                 logMHMCMCposterior/Makefile])
 
 AC_OUTPUT
diff --git a/mex/build/matlab/logMHMCMCposterior/Makefile.am b/mex/build/matlab/logMHMCMCposterior/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..58f0fcc47fbd70eb646f483fc167a56aee7478bc
--- /dev/null
+++ b/mex/build/matlab/logMHMCMCposterior/Makefile.am
@@ -0,0 +1,2 @@
+include ../mex.am
+include ../../logMHMCMCposterior.am
diff --git a/mex/build/octave/Makefile.am b/mex/build/octave/Makefile.am
index 0471b44092889b8f6a201c5bcd94fef42011aeca..ebbc7e7c98088dca1cd38f6c3712c89c73ed794b 100644
--- a/mex/build/octave/Makefile.am
+++ b/mex/build/octave/Makefile.am
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I ../../../m4
 
 # libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
 if DO_SOMETHING
-SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_ logposterior qzcomplex ordschur
+SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_ logposterior logMHMCMCposterior qzcomplex ordschur
 if HAVE_GSL
 SUBDIRS += swz
 endif
diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac
index a30d348fa5219447b7621da7ceb566f4e49effae..3b3177740697bf41645b1e94391d20e7dadea814 100644
--- a/mex/build/octave/configure.ac
+++ b/mex/build/octave/configure.ac
@@ -102,6 +102,7 @@ AC_CONFIG_FILES([Makefile
                  dynare_simul_/Makefile
                  swz/Makefile
                  logposterior/Makefile
+                 logMHMCMCposterior/Makefile
                  qzcomplex/Makefile
                  ordschur/Makefile])
 
diff --git a/mex/build/octave/logMHMCMCposterior/Makefile.am b/mex/build/octave/logMHMCMCposterior/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..d5d3d68d261deb76b7ed58aa22b7320c7e5300b0
--- /dev/null
+++ b/mex/build/octave/logMHMCMCposterior/Makefile.am
@@ -0,0 +1,3 @@
+EXEEXT = .mex
+include ../mex.am
+include ../../logMHMCMCposterior.am
diff --git a/mex/sources/estimation/Makefile.am b/mex/sources/estimation/Makefile.am
index 4277875d535507b30811fa1c1bc5ef31d7e3267c..ee380b038728f552f98830703f393ffdba813ada 100644
--- a/mex/sources/estimation/Makefile.am
+++ b/mex/sources/estimation/Makefile.am
@@ -25,6 +25,7 @@ EXTRA_DIST = \
 	LogLikelihoodMain.cc \
 	LogLikelihoodSubSample.cc \
 	LogLikelihoodSubSample.hh \
+	logMHMCMCposterior.cc \
 	logposterior.cc \
 	LogPosteriorDensity.cc \
 	LogPosteriorDensity.hh \
@@ -34,6 +35,10 @@ EXTRA_DIST = \
 	ModelSolution.hh \
 	Prior.cc \
 	Prior.hh \
+	RandomWalkMetropolisHastings.cc \
+	RandomWalkMetropolisHastings.hh \
+	RandSampler.cc \
+	RandSampler.hh \
 	utils/dynamic_dll.cc \
 	utils/dynamic_dll.hh \
 	utils/ts_exception.h