-
Notifications
You must be signed in to change notification settings - Fork 0
/
Introduction to the algorithm.Rmd
16 lines (13 loc) · 1.16 KB
/
Introduction to the algorithm.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
title: "Introduction to the algorithm"
author: "Hao Zheng (hz2770)"
date: "5/5/2022"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## MCMC
Markov Chain Monte Carlo is combined by two methods, Markov Chain and Monte Carlo Method. Monte Carlo is a random sampling method for approximating a desired quantity, whereas Markov Chain generates a sequence of random variables where the current state only depends on the nearest past in the chain. MCMC algorithm draws samples from Markov Chain successively leading us close to the desired posterior. Two commonly used MCMC algorithm are the Metropolis-Hastings Algorithm and the Gibbs Sampler. Here, we implement the Gibbs Sampler here since we can save much computation cost compared to Metropolis-Hastings Algorithm.
## Gibbs Sampler
Gibbs Sampler is one of Bayesian MCMC approaches with known conditional distributions. By sampling from each random variables given all the others, and changing one random variable at a time, Gibbs Sampler is able to draw parameter samples from the joint distribution. Then given proper starting value, the Markov Chain can reach its stationary distribution.