Mohsen Majidi Pishkenari

0 %
Mohsen Majidi Pishkenari
Data Scientist
Data Analytics
Backend Developer
  • Skype:
    live:561317d219a5d057
  • LinkedIn:
    mohsen ‐majidi‐78aba86a
  • Email:
    majidi_mohsen@alum.sharif.edu
HARD SKILLS
  • Python
  • PHP (laravel)
  • Machine Learning(Pandas, Numpy, sklearn,..)
  • Deep learning (RNN,GAN..)
  • Matlab and Simulink
  • SQL server and MySQL
  • C++
  • Ansys Workbench
SOFT SKILLS
  • Project scheduling
  • Power BI
  • Linux
  • C#
  • Scrum Management
  • Goal and conversion tracking
0

No products in the cart.

Markov-Chain Monte Carlo

24 September 2020

What is Monte Carlo Markov Chain?

Monte Carlo Markov Chain (MCMC) is a computational method used to simulate complex systems and estimate their behavior. It combines the principles of Monte Carlo methods, which rely on random sampling, and Markov chains, which are mathematical models used to describe sequences of events where the probability of each event depends only on the previous event.

In MCMC, a Markov chain is constructed in such a way that its equilibrium distribution matches the desired distribution of interest. This allows for efficient sampling from complex probability distributions that are difficult to directly sample from. MCMC has applications in various fields, including statistics, machine learning, physics, and computational biology.

By iteratively generating samples from the Markov chain, MCMC methods can estimate statistical properties of the target distribution, such as means, variances, or higher-order moments. One popular MCMC algorithm is the Metropolis-Hastings algorithm, which proposes new states based on the current state and accepts or rejects them based on a acceptance probability determined by the target distribution.
 
MCMC has been instrumental in Bayesian inference, where it is used to approximate the posterior distribution of model parameters given observed data. It enables us to make probabilistic statements and quantify uncertainties in a wide range of applications.

We should use MCMC before using any Machine Learning algorithm for two reasons:

1- MCMC has convergence behavior. 

2- It always give unique value.

  •  How it works?
 
To calculate with Monte Carlo Markov Chain (MCMC), you typically follow these steps:
 
1. Define your problem: Determine the objective of your analysis and the specific model or system you want to simulate.
 
2. Formulate the model: Define the variables, parameters, and their relationships within your model. Specify the prior distributions for the parameters if you are performing Bayesian inference.
 
3. Implement the MCMC algorithm: Choose a specific MCMC algorithm, such as the Metropolis-Hastings algorithm or the Gibbs sampler. Implement the algorithm using a programming language or software that supports MCMC, such as Python with libraries like NumPy, PyMC3, or Stan.
 
4. Initialization: Start with an initial state for the parameters of your model. This can be random or informed by prior knowledge.
 
5. Iterative sampling: Generate a sequence of samples by iteratively proposing new states for the parameters based on the current state and accepting or rejecting these proposals according to a specific acceptance criterion. This criterion depends on the target distribution and the chosen MCMC algorithm.
 
6. Burn-in period: Discard a certain number of initial samples (known as the burn-in period) to allow the Markov chain to converge to the target distribution. This helps remove any influence of the initial state.
 
7. Collect samples: Collect a sufficient number of subsequent samples from the Markov chain, typically after the burn-in period. These samples form an approximation of the desired distribution.
 
8. Analyze the samples: Use the collected samples to estimate statistical properties of interest, such as means, variances, or quantiles. You can also visualize the samples or use them for further downstream analyses.

How I deploy this method?

By using “ Computational methods to clarify the influence of cosmic string wakes at the 21cm signal” from real telescope, I deploy MCMC:

  1. At the preprocessing stage, first we have to implement data cleaning and white noise-cleaning.

2.At the modeling stage, we should calculate the “chi-square”:

np.sum((fobs-fexp)**2)

And then try to decrease chi-square.

3.For select next point, I use Gaussian distribution with deviation = 0.005

4.At next stage, we should compare new and old chi-square and try to select the best point.

5.At final stage we should meet white noise for optimum chi-square.

Burnt-in span till meet white noise 

Optimum Chi-Square value vs number of steps

Using Fourier Transform (Real part) to find convergence value of  Chi-Square

Evolution of data modeling 

At this project, I use 25% for “accepted-ratio” and 400000 steps.

The final fitting show that I can find global minimum point and best value for Chi-Square. 

Posted in Python
Write a comment