Skip to content

Instantly share code, notes, and snippets.

View alanzchen's full-sized avatar

Alan Chen alanzchen

View GitHub Profile
@alanzchen
alanzchen / exercise.py
Last active March 10, 2017 16:03
Metropolis-Hasting Algorithm 2 Markov Chain
# coding: utf-8
#r = 8
# p is a probability constructed in the following way:
# node position: 0-0 0-1 0-2 1-0 1-1 1-2 2-0 2-1 2-2
# probability: 1/16 1/8 1/16 1/8 1/4 1/8 1/16 1/8 1/16
# so we have 8 nodes here, and the output will be a way such that the probability is stationary.
p = [0.0625 ,0.1250 ,0.0625 ,0.1250 ,0.2500 ,0.1250,0.0625 ,0.1250 ,0.0625]
#p = [0.5, 0.33333333, 0.166666667]