3 Assume trans0 23 1300 13 13 13 0 0 3414 0 0 01 and using 1
3) Assume trans=[0, 2/3, 1/3,0;0 ,1/3, 1/3, 1/3; 0, 0, 3/4,1/4; 0, 0, 0,1] and using 1,2,3, for the outcomes with emis=[2/5, 3/5, 0; 1/5, 4/5,0; 0,2/3,/1/3; 0,0,1] generate len=100 outcomes using the hmmgnerate fucntion.Print results and save to use them next question. 4) Using equiprobable initial guesses for all the probabilities, with the same dimension for trans and emis as thos in the previous problem; 1)use the outcomes of the third problem to estimate the most liekly trans2 and emis2 using hmmtrain( use the tolerance and maxiteration defaults); and 2) is the previous initial guess a Bakis model? Explain 5) Run hmmgenerate of the model learn in fourth problem and compare it with the model given in the third problem. How good is it?
Solution
Solution :
%****************code
clear all;
clc
len = 100;
trans=[0, 2/3, 1/3,0;0 ,1/3, 1/3, 1/3; 0, 0, 3/4,1/4; 0, 0, 0,1] ;
emis=[2/5, 3/5, 0; 1/5, 4/5,0; 0,2/3,1/3; 0,0,1];
[seq1,states1] = hmmgenerate(len,trans,emis);
trans1=[1/4, 1/4, 1/4,1/4;1/4, 1/4, 1/4,1/4; 1/4, 1/4, 1/4,1/4;1/4, 1/4, 1/4,1/4] ;
emis1=[1/3 1/3 1/3; 1/3 1/3 1/3;1/3 1/3 1/3;1/3 1/3 1/3];
[trans2,emis2] = hmmtrain(seq1,trans1,emis1)
[seq2,states2] = hmmgenerate(len,trans2,emis2);
%*************************************
3.
output seq:
Columns 1 through 19
2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Columns 20 through 38
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Columns 39 through 57
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Columns 58 through 76
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Columns 77 through 95
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Columns 96 through 100
3 3 3 3 3
Output states1
Columns 1 through 18
2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Columns 19 through 36
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Columns 37 through 54
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Columns 55 through 72
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Columns 73 through 90
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Columns 91 through 100
4 4 4 4 4 4 4 4 4 4
=-------
Hmmtrained output :
trans2 =
0.2500 0.2500 0.2500 0.2500
0.2500 0.2500 0.2500 0.2500
0.2500 0.2500 0.2500 0.2500
0.2500 0.2500 0.2500 0.2500
emis2 =
0 0.0300 0.9700
0 0.0300 0.9700
0 0.0300 0.9700
0 0.0300 0.9700
Bakis model is one where no transitions are allowed to states whose indices are lower than the current state
. Clearly the inital equiprobable guess want not Barkis
![3) Assume trans=[0, 2/3, 1/3,0;0 ,1/3, 1/3, 1/3; 0, 0, 3/4,1/4; 0, 0, 0,1] and using 1,2,3, for the outcomes with emis=[2/5, 3/5, 0; 1/5, 4/5,0; 0,2/3,/1/3; 0,0 3) Assume trans=[0, 2/3, 1/3,0;0 ,1/3, 1/3, 1/3; 0, 0, 3/4,1/4; 0, 0, 0,1] and using 1,2,3, for the outcomes with emis=[2/5, 3/5, 0; 1/5, 4/5,0; 0,2/3,/1/3; 0,0](/WebImages/31/3-assume-trans0-23-1300-13-13-13-0-0-3414-0-0-01-and-using-1-1089174-1761573211-0.webp)
![3) Assume trans=[0, 2/3, 1/3,0;0 ,1/3, 1/3, 1/3; 0, 0, 3/4,1/4; 0, 0, 0,1] and using 1,2,3, for the outcomes with emis=[2/5, 3/5, 0; 1/5, 4/5,0; 0,2/3,/1/3; 0,0 3) Assume trans=[0, 2/3, 1/3,0;0 ,1/3, 1/3, 1/3; 0, 0, 3/4,1/4; 0, 0, 0,1] and using 1,2,3, for the outcomes with emis=[2/5, 3/5, 0; 1/5, 4/5,0; 0,2/3,/1/3; 0,0](/WebImages/31/3-assume-trans0-23-1300-13-13-13-0-0-3414-0-0-01-and-using-1-1089174-1761573211-1.webp)