Mercurial > hg > camir-ismir2012
comparison toolboxes/FullBNT-1.0.7/bnt/examples/static/Models/Old/mk_hmm_bnet.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cc4b1211e677 |
---|---|
1 function [bnet, onodes] = mk_hmm_bnet(T, Q, O, cts_obs, param_tying) | |
2 % MK_HMM_BNET Make a (static( bnet to represent a hidden Markov model | |
3 % [bnet, onodes] = mk_hmm_bnet(T, Q, O, cts_obs, param_tying) | |
4 % | |
5 % T = num time slices | |
6 % Q = num hidden states | |
7 % O = size of the observed node (num discrete values or length of vector) | |
8 % cts_obs - 1 means the observed node is a continuous-valued vector, 0 means it's discrete | |
9 % param_tying - 1 means we create 3 CPDs, 0 means we create 1 CPD per node | |
10 | |
11 N = 2*T; | |
12 dag = zeros(N); | |
13 for i=1:T-1 | |
14 dag(i,i+1)=1; | |
15 end | |
16 onodes = T+1:N; | |
17 for i=1:T | |
18 dag(i, onodes(i)) = 1; | |
19 end | |
20 | |
21 if cts_obs | |
22 dnodes = 1:T; | |
23 else | |
24 dnodes = 1:N; | |
25 end | |
26 ns = [Q*ones(1,T) O*ones(1,T)]; | |
27 | |
28 if param_tying | |
29 eclass = [1 2*ones(1,T-1) 3*ones(1,T)]; | |
30 else | |
31 eclass = 1:N; | |
32 end | |
33 | |
34 bnet = mk_bnet(dag, ns, dnodes, eclass); | |
35 | |
36 hnodes = mysetdiff(1:N, onodes); | |
37 if ~param_tying | |
38 for i=hnodes(:)' | |
39 bnet.CPD{i} = tabular_CPD(bnet, i); | |
40 end | |
41 if cts_obs | |
42 for i=onodes(:)' | |
43 bnet.CPD{i} = gaussian_CPD(bnet, i); | |
44 end | |
45 else | |
46 for i=onodes(:)' | |
47 bnet.CPD{i} = tabular_CPD(bnet, i); | |
48 end | |
49 end | |
50 else | |
51 bnet.CPD{1} = tabular_CPD(bnet, 1); | |
52 bnet.CPD{2} = tabular_CPD(bnet, 2); | |
53 if cts_obs | |
54 bnet.CPD{3} = gaussian_CPD(bnet, 3); | |
55 else | |
56 bnet.CPD{3} = tabular_CPD(bnet, 3); | |
57 end | |
58 end |