Discussing the article: "MCMC Sampling Methods — The Metropolis-Hastings Algorithm"

 

Check out the new article: MCMC Sampling Methods — The Metropolis-Hastings Algorithm.

The Metropolis-Hastings algorithm is a fundamental Markov chain Monte Carlo (MCMC) method that is widely used to approximate posterior distributions in Bayesian inference. This article describes the theoretical foundations of the algorithm, the implementation of the MHSampler class in MQL5, and examples of its application, including an analysis of the resulting samples.

Markov chain Monte Carlo (MCMC) methods are a class of sampling algorithms that allow one to draw samples from a complex target distribution p(x). The goal of MCMC is to obtain a set of samples that accurately represent this target distribution so that the means, variances, and other characteristics of this distribution can be estimated. MCMC is based on constructing a Markov chain whose stationary distribution coincides with the target distribution.

These methods are widely used in Bayesian inference, machine learning, and other fields where approximations of posterior distributions are required. Unlike deterministic methods such as variational inference or Laplace approximation, MCMC algorithms have a unique property: when properly configured, they are guaranteed in the limit to produce samples that exactly match the target distribution. Among the many MCMC algorithms, the Metropolis-Hastings (MH) algorithm holds a special place — it is a fundamental method that underlies many modern approaches.

In this article, we will examine the Metropolis-Hastings algorithm, starting with its theoretical foundations and key concepts. Next, we will present an implementation of the algorithm in MQL5 as the MHSampler class, and we will also examine simple examples of its application to univariate and multivariate distributions, including the Random Walk and Independent MH variants.


Author: Evgeniy Chernish

 
Great article, supar.
Could you provide some sample code, for example, showing how to predict the next two bars of the RSI indicator (t+2) using the MCMC method, or how to use MCMC as a smoothing average?
 
cemal bars of the RSI indicator (t+2) using the MCMC method, or how to use MCMC as a smoothing average?

MCMC is not a model that forecasts data; it is a sampler that generates samples from the target distribution you are interested in.