annotate toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@stable_ho_inf_engine/test_ho_inf_enginge.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 function [engine,engine2] = test_ho_inf_enginge(order,T)
wolffd@0 2
wolffd@0 3 assert(order >= 1)
wolffd@0 4 % Model a SISO system, i. e. all node are one-dimensional
wolffd@0 5 % The nodes are numbered as follows
wolffd@0 6 % u(t) = 1 input
wolffd@0 7 % y(t) = 2 model output
wolffd@0 8 % z(t) = 3 noise
wolffd@0 9 % q(t) = 4 observed output = noise + model output
wolffd@0 10
wolffd@0 11 ns = [1 1 1 1];
wolffd@0 12
wolffd@0 13 % Model a linear system, i.e. there are no discrete nodes
wolffd@0 14 dn = [];
wolffd@0 15
wolffd@0 16 % Modeling of connections within a time slice
wolffd@0 17 intra = zeros(4);
wolffd@0 18 intra(2,4) = 1; % Connection y(t) -> q(t)
wolffd@0 19 intra(3,4) = 1; % Connection z(t) -> q(t)
wolffd@0 20
wolffd@0 21 % Connections to the next time slice
wolffd@0 22 inter = zeros(4,4,order);
wolffd@0 23 inter(1,2,1) = 1; % u(t) -> y(t+1);
wolffd@0 24 inter(2,2,1) = 1; %y(t) -> y(t+1);
wolffd@0 25 inter(3,3,1) = 1; %z(t) -> z(t+1);
wolffd@0 26
wolffd@0 27 if order >= 2
wolffd@0 28 inter(1,2,2) = 1; % u(t) -> y(t+2);
wolffd@0 29 inter(2,2,2) = 1; % y(t) -> y(t+2);
wolffd@0 30 end
wolffd@0 31
wolffd@0 32 for i = 3: order
wolffd@0 33 inter(:,:,i) = inter(:,:,i-1); %u(t) -> y(t+i) y(t) -> y(t) +i
wolffd@0 34 end;
wolffd@0 35
wolffd@0 36
wolffd@0 37 % Compution of a higer order Markov Model
wolffd@0 38 bnet = mk_higher_order_dbn(intra,inter,ns,'discrete',dn);
wolffd@0 39 bnet2 = mk_dbn(intra,inter(:,:,1),ns,'discrete',dn)
wolffd@0 40
wolffd@0 41
wolffd@0 42 %Calculation of the number of nodes with different parameters
wolffd@0 43 %There is one input and one output nodes 2
wolffd@0 44 %There are two different disturbance node 2
wolffd@0 45 %There are order +1 nodes for y 1 + order
wolffd@0 46 numOfNodes = 5 + order;
wolffd@0 47
wolffd@0 48 % First input node
wolffd@0 49 bnet.CPD{1} = gaussian_CPD(bnet,1,'mean',0);
wolffd@0 50 bnet2.CPD{1} = gaussian_CPD(bnet,1,'mean',0);
wolffd@0 51 % Modeled output
wolffd@0 52 bnet.CPD{2} = gaussian_CPD(bnet,2,'mean',0);
wolffd@0 53 bnet2.CPD{2} = gaussian_CPD(bnet,2,'mean',0);
wolffd@0 54 %Disturbance
wolffd@0 55 bnet.CPD{3} = gaussian_CPD(bnet,3,'mean',0);
wolffd@0 56 bnet2.CPD{3} = gaussian_CPD(bnet,3,'mean',0);
wolffd@0 57
wolffd@0 58 %Qutput
wolffd@0 59 bnet.CPD{4} = gaussian_CPD(bnet,4,'mean',0);
wolffd@0 60 bnet2.CPD{4} = gaussian_CPD(bnet,4,'mean',0);
wolffd@0 61
wolffd@0 62
wolffd@0 63 %Output node in the second time-slice
wolffd@0 64 %Remember that node number 6 is an example for
wolffd@0 65 %the fifth equivalence class
wolffd@0 66 bnet.CPD{5} = gaussian_CPD(bnet,6,'mean',0);
wolffd@0 67 bnet2.CPD{5} = gaussian_CPD(bnet,6,'mean',0);
wolffd@0 68
wolffd@0 69 %Disturbance node in the second time slice
wolffd@0 70 bnet.CPD{6} = gaussian_CPD(bnet,7,'mean',0);
wolffd@0 71 bnet2.CPD{6} = gaussian_CPD(bnet,7,'mean',0);
wolffd@0 72
wolffd@0 73 % Modeling of the remaining nodes for y
wolffd@0 74 for i = 7:numOfNodes
wolffd@0 75 bnet.CPD{i} = gaussian_CPD(bnet,(i - 6)*4 + 7,'mean',0);
wolffd@0 76 end
wolffd@0 77
wolffd@0 78 % Generation of the inference engine
wolffd@0 79 engine = dv_unrolled_dbn_inf_engine(bnet,T);
wolffd@0 80 engine2 = jtree_unrolled_dbn_inf_engine(bnet,T);
wolffd@0 81
wolffd@0 82
wolffd@0 83
wolffd@0 84
wolffd@0 85
wolffd@0 86
wolffd@0 87