annotate toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/arhmm1.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 % Make an HMM with autoregressive Gaussian observations (switching AR model)
wolffd@0 2 % X1 -> X2
wolffd@0 3 % | |
wolffd@0 4 % v v
wolffd@0 5 % Y1 -> Y2
wolffd@0 6
wolffd@0 7 seed = 0;
wolffd@0 8 rand('state', seed);
wolffd@0 9 randn('state', seed);
wolffd@0 10
wolffd@0 11 intra = zeros(2);
wolffd@0 12 intra(1,2) = 1;
wolffd@0 13 inter = zeros(2);
wolffd@0 14 inter(1,1) = 1;
wolffd@0 15 inter(2,2) = 1;
wolffd@0 16 n = 2;
wolffd@0 17
wolffd@0 18 Q = 2; % num hidden states
wolffd@0 19 O = 2; % size of observed vector
wolffd@0 20
wolffd@0 21 ns = [Q O];
wolffd@0 22 dnodes = 1;
wolffd@0 23 onodes = [2];
wolffd@0 24 bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'observed', onodes);
wolffd@0 25
wolffd@0 26 bnet.CPD{1} = tabular_CPD(bnet, 1);
wolffd@0 27 bnet.CPD{2} = gaussian_CPD(bnet, 2);
wolffd@0 28 bnet.CPD{3} = tabular_CPD(bnet, 3);
wolffd@0 29 bnet.CPD{4} = gaussian_CPD(bnet, 4);
wolffd@0 30
wolffd@0 31
wolffd@0 32 T = 10; % fixed length sequences
wolffd@0 33
wolffd@0 34 engine = {};
wolffd@0 35 %engine{end+1} = hmm_inf_engine(bnet);
wolffd@0 36 engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T);
wolffd@0 37 %engine{end+1} = smoother_engine(hmm_2TBN_inf_engine(bnet));
wolffd@0 38 %engine{end+1} = smoother_engine(jtree_2TBN_inf_engine(bnet));
wolffd@0 39
wolffd@0 40 inf_time = cmp_inference_dbn(bnet, engine, T, 'check_ll',1);
wolffd@0 41 learning_time = cmp_learning_dbn(bnet, engine, T, 'check_ll', 1);
wolffd@0 42