-
Notifications
You must be signed in to change notification settings - Fork 6
/
make_chmm.unused
69 lines (49 loc) · 1.35 KB
/
make_chmm.unused
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [chmm] = make_chmm(N,Q,X)
assert( N == size(Q,2), 'Q must be in the size of [1 N]' );
assert( N == size(X,2), 'X must be in the size of [1 N]' );
% chmm = mk_chmm(N,Q, X);
%{
My version. Might work.
sliceSize = N * 2;
intra = zeros(sliceSize);
intra(1, 3) = 1;
intra(2, 4) = 1;
inter = zeros(sliceSize);
inter(1, [1 2]) = 1;
inter(2, [1 2]) = 1;
observedNodes = [3 4];
hiddenNodes = [3 4];
ns = [Q X];
chmm = mk_dbn(intra, inter, ns)
%}
% Modified from mk_chmm.m
ss = N*2;
hnodes = 1:N;
onodes = (1:N)+N;
intra = zeros(ss);
for i=1:N
intra(hnodes(i), onodes(i))=1;
end
inter = zeros(ss);
for i=1:N
inter(i, max(i-1,1):min(i+1,N))=1;
end
ns = [Q X];
eclass1 = [hnodes onodes];
eclass2 = [hnodes+ss onodes];
dnodes = hnodes;
chmm = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'eclass1', eclass1, 'eclass2', eclass2, ...
'observed', onodes);
for i=hnodes(:)'
chmm.CPD{i} = tabular_CPD(chmm, i);
end
for i=onodes(:)'
chmm.CPD{i} = gaussian_CPD(chmm, i);
end
for i=hnodes(:)'+ss
chmm.CPD{i} = tabular_CPD(chmm, i);
end
% if ~exist(chmm,'var')
% error('Implement make_chmm (inside trainCHMM.m)');
% end
end