How to Use the Influence Model Toolbox for Matlab ?

> addpath 'C:\MATLAB7\work\influence'
> bnet = mk_influence(2*ones(1,6), 2*ones(1,6));
> for i=1:bnet.nchains
> for j=1:bnet.nchains
> bnet.A{i,j} = [.99 .01;.08 .92];
> end
> end
> for i=1:bnet.nchains
> %bnet.B{i} = eye(2);
> bnet.B{i} = [.9 .1;.1 .9]; % add some noises
> end
> bnet.T = 0*bnet.T;
> bnet.T(1:3,1:3) = 1/3*ones(3);
> bnet.T(4:6,4:6) = 1/3*ones(3);
> seq = sample_influence(bnet,1000);
> seq0 = permute(seq(2,:,:),[2 3 1]); % observations
> seq1 = cell2num(permute(seq(1,:,:),[2 3 1])); % latent states > imagesc(cell2num(seq0))

> bnet1 = mk_influence(2*ones(1,6), 2*ones(1,6));
> engine = influence_inf_engine(bnet1);
> bnet1 = learn_params_influence(engine,seq0,50);
> influence = influence_matrix(bnet1);
> imagesc(influence)


> engine1 = influence_inf_engine(bnet1);
> seq2 = influence_mpe(engine1,seq0); > for i=1:size(seq2,1)
> if sum(seq2(i,:)==1)<sum(seq2(i,:)==2)
> seq2(i,:) = 3-seq2(i,:);
>
> tmp = influence(2*i-1,:);
> influence(2*i-1,:) = influence(2*i,:);
> influence(2*i,:) = tmp;
>
> tmp = influence(:,2*i-1);
> influence(:,2*i-1) = influence(:,2*i);
> influence(:,2*i) = tmp;
> end
> end
> imagesc(seq2)

> bnet = mk_influence(2*ones(1,6), 1*ones(1,6), 'cccccc');
> for i=1:bnet.nchains
> for j=1:bnet.nchains
> bnet.A{i,j} = [.99 .01;.08 .92];
> end
> end
> for i=1:bnet.nchains
> bnet.B{i} = [-.25;.25];
> bnet.cov{i} = repmat(eye(bnet.m_outputs(i)),[1 1 bnet.n_states(1)]);
> end
> bnet.T = 0*bnet.T;
> bnet.T(1:3,1:3) = 1/3*ones(3);
> bnet.T(4:6,4:6) = 1/3*ones(3);
> seq = sample_influence(bnet,1000);
> seq0 = permute(seq(2,:,:),[2 3 1]); % observations
> bnet1 = mk_influence(2*ones(1,6), 1*ones(1,6),'cccccc');
> bnet1 = initialize_mu(bnet1,seq0);
> engine = influence_inf_engine(bnet1);
> [bnet1,ll,engine1] = learn_params_influence(engine,seq0,500);
> seq2 = influence_mpe(engine1,seq0);