2.2 Markov Chain

A Markov chain is a stochastic process where we transition from one state to another state using a simple sequential procedure. We start a Markov chain at some state $x^{(1)}$ and use a transition function $p(x^{t}|x^{(t-1)})$, to determine the next state $x^{(2)}$ conditional on the last state. We then keep iterating to create a sequence of states: $$x^{(1)}->x^{(2)}->....->x^{(t)}->...$$. Each such a sequence of states is called a Markov chain or simply chain. The procedure for generating a sequence of T states from a Markov chain is the following: 

(1) Set t = 1

(2) Generate a initial value $u$, and set $x^{(t)}=u$

(3) Repeat 

  t=t+1;

  Sample a new value $u$ from the transition function $p(x^{t}|x^{(t-1)})$;

  Set $x^{(t)}=u$;

(4) Until t = T

Each Markov chain wanders around the state space and the transition to a new state is only dependent on the last state. If we start a number of chains, each with different initial conditions, the chains will initially(not eventually) be in a state close to the starting state, which is called the burn-in state(see the picture below). The starting state of the chain no affects the state of the chain after a sufficiently long sequence of transitions, which is called steady state(see the picture below). This property that Markov chains converge to a stationary distribution regardless of where we started, is quite important. 

HOMEWORK

Implement the Markov chain involving single continuous variable $x$ under the distribution $$Beta(200(0.9x^{(t-1)}+0.05),200(1-0.9x^{(t-1)}-0.05))$$. Create an illustration similar to the Figure above. Start the Markov chain with four different initial values uniformly drawn from [0,1].

Tip: if X is a $T \times K$ matrix in Matlab such that X(t, k) stores the state of the k th Markov chain at the t th iteration, the command plot(X) will simultaneously display the K sequences in different colors.

 1 fa=inline('200*(0.9*x+0.05)','x');%parameter a for beta 
 2 fb=inline('200*(1-0.9*x-0.05)','x');%parameter b for beta
 3 no4mc=4;%4 markove chains
 4 states=unifrnd(0,1,1,no4mc);%initial states
 5 N=200;%200 samples drawn from 4 chains
 6 X=states;
 7 for i=1:N
 8 states=betarnd(fa(states),fb(states));
 9 X=[X;states];
10 end;
11 plot(X);
12 pause;

 

转载于:https://www.cnblogs.com/chaseblack/p/5221814.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值