Let
be a finite Markov chain
with transition matrix
. We want to compute :
Question 1
Write a first routine which returns a stochastic matrix
NxN. |
Question 2
Using the choosen matrix
grand in Scilab). |
Question 3
Choosing an instantaneous cost
max
function can be used to get the maximum value of two quantities but also to get the indice of
the value which realize the max. |
// A stoping time problem. c=... // instantaneous cost K=... // final cost r=0.05; C=ones(N,T); // a matrix to store the value function U=2*ones(N,T); // a matrix to store the control (1 or 2) C(:,T) = ... ; for i=T-1:-1:1 .... C(:,i)= Ci; U(:,i)= ki; end plot3d(1:N,1:T,C)
Question 4
Using samples of the markov chain for a given starting state evaluate
by Monte Carlo the cost function
|
m=10000; // number of samplings Cm=0; // we want to evaluate C(1,1); for k=1:m // loop on sampling // the k-th trajectory. X=.... // sample a trajectory // the control along the trajectory for i=1:T, u(i)=... end stop=... // the stopping time cost=0; ... cost = .. // evaluate the cost for the m-th trajectory Cm=Cm+cost/m; // compute the mean end