// TP06_19: Modèle markovien pour le micro-crédit
clear;clc;//nettoyage mémoires et console
alpha=0.9;
gam=0.3;
Q=[1-gam,gam;1-alpha,alpha]
[pitranspo,diagevals]=spec(Q')
ppi=pitranspo'
// vérif:
ppi*Q
pi=ppi(2,:)/sum(ppi(2,:))
// vérif:
pi*Q
pi-pi*Q
// question 4
Q^50
Q^3
Q^10
pi0=[0.9,0.1]
pi0*Q^3
pi0*Q^10
Q1=[1-gam,gam,0;0,alpha,1-alpha;1,0,0]
Q2=[1-gam,gam,0,0;0,alpha,1-alpha,0;0,0,0,1;1,0,0,0]
Q1^3
Q2^3
Q1^10
Q2^10

Q1^50
Q2^50

pi10=[0.9,0.1,0]
pi20=[0.9,0.1,0,0]

pi10*Q1^3
pi20*Q2^3
pi10*Q1^10
pi20*Q2^10

// 
alphaS=0.92
alphaR=0.22
gam=0.3
bet=0.5
QQ=[alphaS,1-alphaS,0;gam*bet,1-gam,gam*(1-bet);0,1-alphaR,alphaR]
QQ^50
[pppitranspo,ddiagevals]=spec(QQ')
ddiagevals
pppi=pppitranspo'
ppi=pppi(1,:)/sum(pppi(1,:))
ppi*QQ
ppi-ppi*QQ

