comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@hhmm2Q_CPD/hhmm2Q_CPD.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function CPD = hhmm2Q_CPD(bnet, self, varargin)
2 % HHMMQ_CPD Make the CPD for a Q node in a 2 level hierarchical HMM
3 % CPD = hhmmQ_CPD(bnet, self, ...)
4 %
5 % Fself(t-1) Qps
6 % \ |
7 % \ v
8 % Qold(t-1) -> Q(t)
9 % /
10 % /
11 % Fbelow(t-1)
12 %
13 %
14 % optional args [defaults]
15 %
16 % Fself - node number <= ss
17 % Fbelow - node number <= ss
18 % Qps - node numbers (all <= 2*ss) - uses 2TBN indexing
19 % transprob - CPT for when Fbelow=2 and Fself=1
20 % startprob - CPT for when Fbelow=2 and Fself=2
21 % If Fbelow=1, we cannot change state.
22
23 ss = bnet.nnodes_per_slice;
24 ns = bnet.node_sizes(:);
25
26 % set default arguments
27 Fself = [];
28 Fbelow = [];
29 Qps = [];
30 startprob = [];
31 transprob = [];
32
33 for i=1:2:length(varargin)
34 switch varargin{i},
35 case 'Fself', Fself = varargin{i+1};
36 case 'Fbelow', Fbelow = varargin{i+1};
37 case 'Qps', Qps = varargin{i+1};
38 case 'transprob', transprob = varargin{i+1};
39 case 'startprob', startprob = varargin{i+1};
40 end
41 end
42
43 ps = parents(bnet.dag, self);
44 old_self = self-ss;
45 ndsz = ns(:)';
46 CPD.dom_sz = [ndsz(ps) ns(self)];
47 CPD.Fself_ndx = find_equiv_posns(Fself, ps);
48 CPD.Fbelow_ndx = find_equiv_posns(Fbelow, ps);
49 Qps = mysetdiff(ps, [Fself Fbelow old_self]);
50 CPD.Qps_ndx = find_equiv_posns(Qps, ps);
51 CPD.old_self_ndx = find_equiv_posns(old_self, ps);
52
53 Qps = ps(CPD.Qps_ndx);
54 CPD.Qsz = ns(self);
55 CPD.Qpsizes = ns(Qps);
56
57 CPD.transprob = transprob;
58 CPD.startprob = startprob;
59 CPD.start_counts = [];
60 CPD.trans_counts = [];
61
62 CPD = class(CPD, 'hhmm2Q_CPD', discrete_CPD(0, CPD.dom_sz));
63
64
65