Daniel@0: % Test whether stable conditional Gaussian inference works Daniel@0: % Make a linear dynamical system Daniel@0: % X1 -> X2 Daniel@0: % | | Daniel@0: % v v Daniel@0: % Y1 Y2 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: n = 2; Daniel@0: Daniel@0: X = 2; % size of hidden state Daniel@0: Y = 2; % size of observable state Daniel@0: Daniel@0: ns = [X Y]; Daniel@0: bnet = mk_dbn(intra, inter, ns, 'discrete', [], 'observed', 2); Daniel@0: Daniel@0: x0 = rand(X,1); Daniel@0: V0 = eye(X); Daniel@0: C0 = rand(Y,X); Daniel@0: R0 = eye(Y); Daniel@0: A0 = rand(X,X); Daniel@0: Q0 = eye(X); Daniel@0: Daniel@0: bnet.CPD{1} = gaussian_CPD(bnet, 1, 'mean', x0, 'cov', V0); Daniel@0: bnet.CPD{2} = gaussian_CPD(bnet, 2, 'mean', zeros(Y,1), 'cov', R0, 'weights', C0); Daniel@0: bnet.CPD{3} = gaussian_CPD(bnet, 3, 'mean', zeros(X,1), 'cov', Q0, 'weights', A0); Daniel@0: Daniel@0: Daniel@0: T = 5; % fixed length sequences Daniel@0: Daniel@0: engine = {}; Daniel@0: engine{end+1} = kalman_inf_engine(bnet); Daniel@0: engine{end+1} = scg_unrolled_dbn_inf_engine(bnet, T); Daniel@0: engine{end+1} = jtree_unrolled_dbn_inf_engine(bnet, T); Daniel@0: Daniel@0: inf_time = cmp_inference_dbn(bnet, engine, T, 'check_ll', 0);