annotate toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/Old/online2.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 N = 1; % regular HMM
wolffd@0 2 Q = 2;
wolffd@0 3 ss = 2;
wolffd@0 4 hnodes = 1;
wolffd@0 5 onodes = 2;
wolffd@0 6
wolffd@0 7 rand('state', 0);
wolffd@0 8 randn('state', 0);
wolffd@0 9 O = 2;
wolffd@0 10 discrete_obs = 1;
wolffd@0 11 bnet = mk_chmm(N, Q, O, discrete_obs);
wolffd@0 12 ns = bnet.node_sizes_slice;
wolffd@0 13
wolffd@0 14 engine = hmm_inf_engine(bnet, onodes);
wolffd@0 15
wolffd@0 16 T = 4;
wolffd@0 17 ev = cell(ss,T);
wolffd@0 18 ev(onodes,:) = num2cell(sample_discrete([0.5 0.5], N, T));
wolffd@0 19
wolffd@0 20
wolffd@0 21 engine = dbn_init_bel(engine);
wolffd@0 22 for t=1:T
wolffd@0 23 if t==1
wolffd@0 24 [engine, ll(t)] = dbn_update_bel1(engine, ev(:,t));
wolffd@0 25 else
wolffd@0 26 [engine, ll(t)] = dbn_update_bel(engine, ev(:,t-1:t));
wolffd@0 27 end
wolffd@0 28 % one-step ahead prediction
wolffd@0 29 lag = 1;
wolffd@0 30 engine2 = dbn_predict_bel(engine, lag);
wolffd@0 31 marg = dbn_marginal_from_bel(engine2, 1)
wolffd@0 32 marg = dbn_marginal_from_bel(engine2, 2)
wolffd@0 33 end