diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/BNT/examples/dynamic/mk_fhmm.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/BNT/examples/dynamic/mk_fhmm.m')
| -rw-r--r-- | sourcecodes/bnt-master/BNT/examples/dynamic/mk_fhmm.m | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/mk_fhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/mk_fhmm.m new file mode 100644 index 00000000..ffbe05a5 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/mk_fhmm.m @@ -0,0 +1,58 @@ +function bnet = mk_fhmm(N, Q, Y, discrete_obs) +% MK_FHMM Make a factorial Hidden Markov Model +% +% There are N independent parallel hidden chains, each connected to the output +% +% e.g., N = 2 (vertical/diagonal edges point down) +% +% A1--->A2 +% | B1--|->B2 +% | / |/ +% Y1 Y2 +% +% [bnet, onode] = mk_chmm(n, q, y, discrete_obs) +% +% Each hidden node is discrete and has Q values. +% If discrete_obs = 1, each observed node is discrete and has values 1..Y. +% If discrete_obs = 0, each observed node is a Gaussian vector of length Y. + +if nargin < 2, Q = 2; end +if nargin < 3, Y = 2; end +if nargin < 4, discrete_obs = 1; end + +ss = N+1; +hnodes = 1:N; +onode = N+1; + +intra = zeros(ss); +intra(hnodes, onode) = 1; + +inter = eye(ss); +inter(onode,onode) = 0; + +ns = [Q*ones(1,N) Y]; + +eclass1 = [hnodes onode]; +eclass2 = [hnodes+ss onode]; +if discrete_obs + dnodes = 1:ss; +else + dnodes = hnodes; +end +bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'eclass1', eclass1, 'eclass2', eclass2, ... + 'observed', onode); + +for i=hnodes(:)' + bnet.CPD{i} = tabular_CPD(bnet, i); +end +i = onode; +if discrete_obs + bnet.CPD{i} = tabular_CPD(bnet, i); +else + bnet.CPD{i} = gaussian_CPD(bnet, i); +end +for i=hnodes(:)'+ss + bnet.CPD{i} = tabular_CPD(bnet, i); +end + + |
