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