Daniel@0: % Make an HMM with autoregressive Gaussian observations (switching AR model) Daniel@0: % X1 -> X2 Daniel@0: % | | Daniel@0: % v v Daniel@0: % Y1 -> Y2 Daniel@0: Daniel@0: seed = 0; Daniel@0: rand('state', seed); Daniel@0: randn('state', seed); Daniel@0: Daniel@0: intra = zeros(2); Daniel@0: intra(1,2) = 1; Daniel@0: inter = zeros(2); Daniel@0: inter(1,1) = 1; Daniel@0: inter(2,2) = 1; Daniel@0: n = 2; Daniel@0: Daniel@0: Q = 2; % num hidden states Daniel@0: O = 2; % size of observed vector Daniel@0: Daniel@0: ns = [Q O]; Daniel@0: dnodes = 1; Daniel@0: onodes = [2]; Daniel@0: bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'observed', onodes); Daniel@0: Daniel@0: bnet.CPD{1} = tabular_CPD(bnet, 1); Daniel@0: bnet.CPD{2} = gaussian_CPD(bnet, 2); Daniel@0: bnet.CPD{3} = tabular_CPD(bnet, 3); Daniel@0: bnet.CPD{4} = gaussian_CPD(bnet, 4); Daniel@0: Daniel@0: Daniel@0: T = 10; % fixed length sequences Daniel@0: Daniel@0: engine = {}; Daniel@0: %engine{end+1} = hmm_inf_engine(bnet); Daniel@0: engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T); Daniel@0: %engine{end+1} = smoother_engine(hmm_2TBN_inf_engine(bnet)); Daniel@0: %engine{end+1} = smoother_engine(jtree_2TBN_inf_engine(bnet)); Daniel@0: Daniel@0: inf_time = cmp_inference_dbn(bnet, engine, T, 'check_ll',1); Daniel@0: learning_time = cmp_learning_dbn(bnet, engine, T, 'check_ll', 1); Daniel@0: