diff options
Diffstat (limited to 'sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square')
23 files changed, 2667 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Entries b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Entries new file mode 100644 index 00000000..fdee19ae --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Entries @@ -0,0 +1,14 @@ +/get_square_data.m/1.1.1.1/Wed May 29 15:59:54 2002// +/hhmm_inference.m/1.1.1.1/Wed May 29 15:59:54 2002// +/is_F2_true_D3.m/1.1.1.1/Wed May 29 15:59:54 2002// +/learn_square_hhmm_cts.m/1.1.1.1/Thu Jun 20 00:19:22 2002// +/learn_square_hhmm_discrete.m/1.1.1.1/Wed May 29 15:59:54 2002// +/mk_square_hhmm.m/1.1.1.1/Wed May 29 15:59:54 2002// +/plot_square_hhmm.m/1.1.1.1/Wed May 29 15:59:54 2002// +/sample_square_hhmm_cts.m/1.1.1.1/Wed May 29 15:59:54 2002// +/sample_square_hhmm_discrete.m/1.1.1.1/Wed May 29 15:59:54 2002// +/square4.mat/1.1.1.1/Wed May 29 15:59:54 2002// +/square4_cases.mat/1.1.1.1/Wed May 29 15:59:54 2002// +/test_square_fig.m/1.1.1.1/Wed May 29 15:59:54 2002// +/test_square_fig.mat/1.1.1.1/Wed May 29 15:59:54 2002// +D/Old//// diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Repository b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Repository new file mode 100644 index 00000000..e926a0d5 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Repository @@ -0,0 +1 @@ +FullBNT/BNT/examples/dynamic/HHMM/Square diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Root b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Root new file mode 100644 index 00000000..f3bd14a6 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/CVS/Root @@ -0,0 +1 @@ +:ext:nsaunier@bnt.cvs.sourceforge.net:/cvsroot/bnt diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Entries b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Entries new file mode 100644 index 00000000..6d415d0d --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Entries @@ -0,0 +1,5 @@ +/learn_square_hhmm.m/1.1.1.1/Wed May 29 15:59:54 2002// +/mk_square_hhmm.m/1.1.1.1/Wed May 29 15:59:54 2002// +/plot_square_hhmm.m/1.1.1.1/Wed May 29 15:59:54 2002// +/sample_square_hhmm.m/1.1.1.1/Wed May 29 15:59:54 2002// +D diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Repository b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Repository new file mode 100644 index 00000000..47df1a8c --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Repository @@ -0,0 +1 @@ +FullBNT/BNT/examples/dynamic/HHMM/Square/Old diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Root b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Root new file mode 100644 index 00000000..f3bd14a6 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/CVS/Root @@ -0,0 +1 @@ +:ext:nsaunier@bnt.cvs.sourceforge.net:/cvsroot/bnt diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/learn_square_hhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/learn_square_hhmm.m new file mode 100644 index 00000000..695ae047 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/learn_square_hhmm.m @@ -0,0 +1,294 @@ +% Learn a 3 level HHMM similar to mk_square_hhmm + +% Because startprob should be shared for t=1:T, +% but in the DBN is shared for t=2:T, we train using a single long sequence. + +discrete_obs = 0; +supervised = 1; +obs_finalF2 = 0; +% It is not possible to observe F2 if we learn +% because the update_ess method for hhmmF_CPD and hhmmQ_CPD assume +% the F nodes are always hidden (for speed). +% However, for generating, we might want to set the final F2=true +% to force all subroutines to finish. + +ss = 6; +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +Qnodes = [Q1 Q2 Q3]; Fnodes = [F2 F3]; + +seed = 1; +rand('state', seed); +randn('state', seed); + +if discrete_obs + Qsizes = [2 4 2]; +else + Qsizes = [2 4 1]; +end + +D = 3; +Qnodes = 1:D; +startprob = cell(1,D); +transprob = cell(1,D); +termprob = cell(1,D); + +startprob{1} = 'unif'; +transprob{1} = 'unif'; + +% In the unsupervised case, it is essential that we break symmetry +% in the initial param estimates. +%startprob{2} = 'unif'; +%transprob{2} = 'unif'; +%termprob{2} = 'unif'; +startprob{2} = 'rnd'; +transprob{2} = 'rnd'; +termprob{2} = 'rnd'; + +leftright = 0; +if leftright + % Initialise base-level models as left-right. + % If we initialise with delta functions, + % they will remain delat funcitons after learning + startprob{3} = 'leftstart'; + transprob{3} = 'leftright'; + termprob{3} = 'rightstop'; +else + % If we want to be able to run a base-level model backwards... + startprob{3} = 'rnd'; + transprob{3} = 'rnd'; + termprob{3} = 'rnd'; +end + +if discrete_obs + % Initialise observations of lowest level primitives in a way which we can interpret + chars = ['L', 'l', 'U', 'u', 'R', 'r', 'D', 'd']; + L=find(chars=='L'); l=find(chars=='l'); + U=find(chars=='U'); u=find(chars=='u'); + R=find(chars=='R'); r=find(chars=='r'); + D=find(chars=='D'); d=find(chars=='d'); + Osize = length(chars); + + p = 0.9; + obsprob = (1-p)*ones([4 2 Osize]); + % Q2 Q3 O + obsprob(1, 1, L) = p; + obsprob(1, 2, l) = p; + obsprob(2, 1, U) = p; + obsprob(2, 2, u) = p; + obsprob(3, 1, R) = p; + obsprob(3, 2, r) = p; + obsprob(4, 1, D) = p; + obsprob(4, 2, d) = p; + obsprob = mk_stochastic(obsprob); + Oargs = {'CPT', obsprob}; + +else + % Initialise means of lowest level primitives in a way which we can interpret + % These means are little vectors in the east, south, west, north directions. + % (left-right=east, up-down=south, right-left=west, down-up=north) + Osize = 2; + mu = zeros(2, Qsizes(2), Qsizes(3)); + noise = 0; + scale = 3; + for q3=1:Qsizes(3) + mu(:, 1, q3) = scale*[1;0] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 2, q3) = scale*[0;-1] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 3, q3) = scale*[-1;0] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 4, q3) = scale*[0;1] + noise*rand(2,1); + end + Sigma = repmat(reshape(scale*eye(2), [2 2 1 1 ]), [1 1 Qsizes(2) Qsizes(3)]); + Oargs = {'mean', mu, 'cov', Sigma, 'cov_type', 'diag'}; +end + +bnet = mk_hhmm('Qsizes', Qsizes, 'Osize', Osize', 'discrete_obs', discrete_obs,... + 'Oargs', Oargs, 'Ops', Qnodes(2:3), ... + 'startprob', startprob, 'transprob', transprob, 'termprob', termprob); + +if supervised + bnet.observed = [Q1 Q2 Onode]; +else + bnet.observed = [Onode]; +end + +if obs_finalF2 + engine = jtree_dbn_inf_engine(bnet); + % can't use ndx version because sometimes F2 is hidden, sometimes observed + error('can''t observe F when learning') +else + if supervised + engine = jtree_ndx_dbn_inf_engine(bnet); + else + engine = jtree_hmm_inf_engine(bnet); + end +end + +if discrete_obs + % generate some synthetic data (easier to debug) + cases = {}; + + T = 8; + ev = cell(ss, T); + ev(Onode,:) = num2cell([L l U u R r D d]); + if supervised + ev(Q1,:) = num2cell(1*ones(1,T)); + ev(Q2,:) = num2cell( [1 1 2 2 3 3 4 4]); + end + cases{1} = ev; + cases{3} = ev; + + T = 8; + ev = cell(ss, T); + if leftright % base model is left-right + ev(Onode,:) = num2cell([R r U u L l D d]); + else + ev(Onode,:) = num2cell([r R u U l L d D]); + end + if supervised + ev(Q1,:) = num2cell(2*ones(1,T)); + ev(Q2,:) = num2cell( [3 3 2 2 1 1 4 4]); + end + + cases{2} = ev; + cases{4} = ev; + + if obs_finalF2 + for i=1:length(cases) + T = size(cases{i},2); + cases{i}(F2,T)={2}; % force F2 to be finished at end of seq + end + end + + if 0 + ev = cases{4}; + engine2 = enter_evidence(engine2, ev); + T = size(ev,2); + for t=1:T + m=marginal_family(engine2, F2, t); + fprintf('t=%d\n', t); + reshape(m.T, [2 2]) + end + end + + % [bnet2, LL] = learn_params_dbn_em(engine, cases, 'max_iter', 10); + long_seq = cat(2, cases{:}); + [bnet2, LL, engine2] = learn_params_dbn_em(engine, {long_seq}, 'max_iter', 200); + + % figure out which subsequence each model is responsible for + mpe = calc_mpe_dbn(engine2, long_seq); + pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, chars); + +else + load 'square4_cases' % cases{seq}{i,t} for i=1:ss + %plot_square_hhmm(cases{1}) + %long_seq = cat(2, cases{:}); + train_cases = cases(1:2); + long_seq = cat(2, train_cases{:}); + if ~supervised + T = size(long_seq,2); + for t=1:T + long_seq{Q1,t} = []; + long_seq{Q2,t} = []; + end + end + [bnet2, LL, engine2] = learn_params_dbn_em(engine, {long_seq}, 'max_iter', 100); + + CPDO=struct(bnet2.CPD{eclass(Onode,1)}); + mu = CPDO.mean; + Sigma = CPDO.cov; + CPDO_full = CPDO; + + % force diagonal covs after training + for k=1:size(Sigma,3) + Sigma(:,:,k) = diag(diag(Sigma(:,:,k))); + end + bnet2.CPD{6} = set_fields(bnet.CPD{6}, 'cov', Sigma); + + if 0 + % visualize each model by concatenating means for each model for nsteps in a row + nsteps = 5; + ev = cell(ss, nsteps*prod(Qsizes(2:3))); + t = 1; + for q2=1:Qsizes(2) + for q3=1:Qsizes(3) + for i=1:nsteps + ev{Onode,t} = mu(:,q2,q3); + ev{Q2,t} = q2; + t = t + 1; + end + end + end + plot_square_hhmm(ev) + end + + % bnet3 is the same as the learned model, except we will use it in testing mode + if supervised + bnet3 = bnet2; + bnet3.observed = [Onode]; + engine3 = hmm_inf_engine(bnet3); + %engine3 = jtree_ndx_dbn_inf_engine(bnet3); + else + bnet3 = bnet2; + engine3 = engine2; + end + + if 0 + % segment whole sequence + mpe = calc_mpe_dbn(engine3, long_seq); + pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, []); + end + + % segment each sequence + test_cases = cases(3:4); + for i=1:2 + ev = test_cases{i}; + T = size(ev, 2); + for t=1:T + ev{Q1,t} = []; + ev{Q2,t} = []; + end + mpe = calc_mpe_dbn(engine3, ev); + subplot(1,2,i) + plot_square_hhmm(mpe) + %pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, []); + q1s = cell2num(mpe(Q1,:)); + h = hist(q1s, 1:Qsizes(1)); + map_q1 = argmax(h); + str = sprintf('test seq %d is of type %d\n', i, map_q1); + title(str) + end + +end + +if 0 +% Estimate gotten by couting transitions in the labelled data +% Note that a self transition shouldnt count if F2=off. +Q2ev = cell2num(ev(Q2,:)); +Q2a = Q2ev(1:end-1); +Q2b = Q2ev(2:end); +counts = compute_counts([Q2a; Q2b], [4 4]); +end + +eclass = bnet2.equiv_class; +CPDQ1=struct(bnet2.CPD{eclass(Q1,2)}); +CPDQ2=struct(bnet2.CPD{eclass(Q2,2)}); +CPDQ3=struct(bnet2.CPD{eclass(Q3,2)}); +CPDF2=struct(bnet2.CPD{eclass(F2,1)}); +CPDF3=struct(bnet2.CPD{eclass(F3,1)}); + + +A=add_hhmm_end_state(CPDQ2.transprob, CPDF2.termprob(:,:,2)); +squeeze(A(:,1,:)) +squeeze(A(:,2,:)) +CPDQ2.startprob + +if 0 +S=struct(CPDF2.sub_CPD_term); +S.nsamples +reshape(S.counts, [2 4 2]) +end diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/mk_square_hhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/mk_square_hhmm.m new file mode 100644 index 00000000..608b6784 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/mk_square_hhmm.m @@ -0,0 +1,183 @@ +function bnet = mk_square_hhmm(discrete_obs, true_params, topright) + +% Make a 3 level HHMM described by the following grammar +% +% Square -> CLK | CCK % clockwise or counterclockwise +% CLK -> LR UD RL DU start on top left (1 2 3 4) +% CCK -> RL UD LR DU if start at top right (3 2 1 4) +% CCK -> UD LR DU RL if start at top left (2 1 4 3) +% +% LR = left-right, UD = up-down, RL = right-left, DU = down-up +% LR, UD, RL, DU are sub HMMs. +% +% For discrete observations, the subHMMs are 2-state left-right. +% LR emits L then l, etc. +% +% For cts observations, the subHMMs are 1 state. +% LR emits a vector in the -> direction, with a little noise. +% Since there is no constraint that we remain in the LR state as long as the RL state, +% the sides of the square might have different lengths, +% so the result is not really a square! +% +% If true_params = 0, we use random parameters at the top 2 levels +% (ready for learning). At the bottom level, we use noisy versions +% of the "true" observations. +% +% If topright=1, counter-clockwise starts at top right, not top left +% This example was inspired by Ivanov and Bobick. + +if nargin < 3, topright = 1; end + +if 1 % discrete_obs + Qsizes = [2 4 2]; +else + Qsizes = [2 4 1]; +end + +D = 3; +Qnodes = 1:D; +startprob = cell(1,D); +transprob = cell(1,D); +termprob = cell(1,D); + +% LEVEL 1 + +startprob{1} = 'unif'; +transprob{1} = 'unif'; + +% LEVEL 2 + +if true_params + startprob{2} = zeros(2, 4); + startprob{2}(1, :) = [1 0 0 0]; + if topright + startprob{2}(2, :) = [0 0 1 0]; + else + startprob{2}(2, :) = [0 1 0 0]; + end + + transprob{2} = zeros(4, 2, 4); + + transprob{2}(:,1,:) = [0 1 0 0 + 0 0 1 0 + 0 0 0 1 + 0 0 0 1]; % 4->e + if topright + transprob{2}(:,2,:) = [0 0 0 1 + 1 0 0 0 + 0 1 0 0 + 0 0 0 1]; % 4->e + else + transprob{2}(:,2,:) = [0 0 0 1 + 1 0 0 0 + 0 0 1 0 % 3->e + 0 0 1 0]; + end + + %termprob{2} = 'rightstop'; + termprob{2} = zeros(2,4,2); + pfin = 0.8; + termprob{2}(1,:,2) = [0 0 0 pfin]; % finish in state 4 (DU) + termprob{2}(1,:,1) = 1 - [0 0 0 pfin]; + if topright + termprob{2}(2,:,2) = [0 0 0 pfin]; + termprob{2}(2,:,1) = 1 - [0 0 0 pfin]; + else + termprob{2}(2,:,2) = [0 0 pfin 0]; % finish in state 3 (RL) + termprob{2}(2,:,1) = 1 - [0 0 pfin 0]; + end +else + % In the unsupervised case, it is essential that we break symmetry + % in the initial param estimates. + %startprob{2} = 'unif'; + %transprob{2} = 'unif'; + %termprob{2} = 'unif'; + startprob{2} = 'rnd'; + transprob{2} = 'rnd'; + termprob{2} = 'rnd'; +end + +% LEVEL 3 + +if 1 | true_params + startprob{3} = 'leftstart'; + transprob{3} = 'leftright'; + termprob{3} = 'rightstop'; +else + % If we want to be able to run a base-level model backwards... + startprob{3} = 'rnd'; + transprob{3} = 'rnd'; + termprob{3} = 'rnd'; +end + + +% OBS LEVEl + +if discrete_obs + % Initialise observations of lowest level primitives in a way which we can interpret + chars = ['L', 'l', 'U', 'u', 'R', 'r', 'D', 'd']; + L=find(chars=='L'); l=find(chars=='l'); + U=find(chars=='U'); u=find(chars=='u'); + R=find(chars=='R'); r=find(chars=='r'); + D=find(chars=='D'); d=find(chars=='d'); + Osize = length(chars); + + if true_params + p = 1; % makes each state fully observed + else + p = 0.9; + end + + obsprob = (1-p)*ones([4 2 Osize]); + % Q2 Q3 O + obsprob(1, 1, L) = p; + obsprob(1, 2, l) = p; + obsprob(2, 1, U) = p; + obsprob(2, 2, u) = p; + obsprob(3, 1, R) = p; + obsprob(3, 2, r) = p; + obsprob(4, 1, D) = p; + obsprob(4, 2, d) = p; + obsprob = mk_stochastic(obsprob); + Oargs = {'CPT', obsprob}; +else + % Initialise means of lowest level primitives in a way which we can interpret + % These means are little vectors in the east, south, west, north directions. + % (left-right=east, up-down=south, right-left=west, down-up=north) + Osize = 2; + mu = zeros(2, Qsizes(2), Qsizes(3)); + scale = 3; + if true_params + noise = 0; + else + noise = 0.5*scale; + end + for q3=1:Qsizes(3) + mu(:, 1, q3) = scale*[1;0] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 2, q3) = scale*[0;-1] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 3, q3) = scale*[-1;0] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 4, q3) = scale*[0;1] + noise*rand(2,1); + end + Sigma = repmat(reshape(scale*eye(2), [2 2 1 1 ]), [1 1 Qsizes(2) Qsizes(3)]); + Oargs = {'mean', mu, 'cov', Sigma, 'cov_type', 'diag'}; +end + +if discrete_obs + selfprob = 0.5; +else + selfprob = 0.95; + % If less than this, it won't look like a square + % because it doesn't spend enough time in each state + % Unfortunately, the variance on durations (lengths of each side) + % is very large +end +bnet = mk_hhmm('Qsizes', Qsizes, 'Osize', Osize', 'discrete_obs', discrete_obs, ... + 'Oargs', Oargs, 'Ops', Qnodes(2:3), 'selfprob', selfprob, ... + 'startprob', startprob, 'transprob', transprob, 'termprob', termprob); + diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/plot_square_hhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/plot_square_hhmm.m new file mode 100644 index 00000000..e6701e45 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/plot_square_hhmm.m @@ -0,0 +1,32 @@ +function plot_square_hhmm(ev) +% Plot the square shape implicit in the evidence. +% ev{i,t} is the value of node i in slice t. +% The observed node contains a velocity (delta increment), which is converted +% into a position. +% The Q2 node specifies which model is used; each segment is color-coded +% in the order red, green, blue, black. + +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; + +delta = cell2num(ev(Onode,:)); % delta(:,t) +Q2label = cell2num(ev(Q2,:)); + +T = size(delta, 2); +pos = zeros(2,T+1); +clf +hold on +cols = {'r', 'g', 'b', 'k'}; +boundary = 0; +coli = 1; +for t=2:T+1 + pos(:,t) = pos(:,t-1) + delta(:,t-1); + plot(pos(1,t), pos(2,t), sprintf('%c.', cols{coli})); + if t < T + boundary = (Q2label(t) ~= Q2label(t-1)); + end + if boundary + coli = coli + 1; + coli = mod(coli-1, length(cols)) + 1; + end +end + diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/sample_square_hhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/sample_square_hhmm.m new file mode 100644 index 00000000..a0f9007e --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/Old/sample_square_hhmm.m @@ -0,0 +1,160 @@ + +seed = 0; +rand('state', seed); +randn('state', seed); + +discrete_obs = 1; +topright = 0; + +Qsizes = [2 4 2]; +D = 3; +Qnodes = 1:D; +startprob = cell(1,D); +transprob = cell(1,D); +termprob = cell(1,D); + +% LEVEL 1 + +startprob{1} = 'ergodic'; +transprob{1} = 'ergodic'; + +% LEVEL 2 + +startprob{2} = zeros(2, 4); +startprob{2}(1, :) = [1 0 0 0]; +if topright + startprob{2}(2, :) = [0 0 1 0]; +else + startprob{2}(2, :) = [0 1 0 0]; +end + +transprob{2} = zeros(4, 2, 4); + +transprob{2}(:,1,:) = [0 1 0 0 + 0 0 1 0 + 0 0 0 1 + 0 0 0 1]; % 4->e +if topright + transprob{2}(:,2,:) = [0 0 0 1 + 1 0 0 0 + 0 1 0 0 + 0 0 0 1]; % 4->e +else + transprob{2}(:,2,:) = [0 0 0 1 + 1 0 0 0 + 0 0 1 0 % 3->e + 0 0 1 0]; +end + +%termprob{2} = 'rightstop'; +termprob{2} = zeros(2,4,2); +pfin = 0.8; +termprob{2}(1,:,2) = [0 0 0 pfin]; % finish in state 4 (DU) +termprob{2}(1,:,1) = 1 - [0 0 0 pfin]; +if topright + termprob{2}(2,:,2) = [0 0 0 pfin]; + termprob{2}(2,:,1) = 1 - [0 0 0 pfin]; +else + termprob{2}(2,:,2) = [0 0 pfin 0]; % finish in state 3 (RL) + termprob{2}(2,:,1) = 1 - [0 0 pfin 0]; +end + +% LEVEL 3 + +startprob{3} = 'leftstart'; +transprob{3} = 'leftright'; +termprob{3} = 'rightstop'; + + +% OBS LEVEl + +if discrete_obs + chars = ['L', 'l', 'U', 'u', 'R', 'r', 'D', 'd']; + L=find(chars=='L'); l=find(chars=='l'); + U=find(chars=='U'); u=find(chars=='u'); + R=find(chars=='R'); r=find(chars=='r'); + D=find(chars=='D'); d=find(chars=='d'); + Osize = length(chars); + + obsprob = zeros([4 2 Osize]); + % Q2 Q3 O + obsprob(1, 1, L) = 1.0; + obsprob(1, 2, l) = 1.0; + obsprob(2, 1, U) = 1.0; + obsprob(2, 2, u) = 1.0; + obsprob(3, 1, R) = 1.0; + obsprob(3, 2, r) = 1.0; + obsprob(4, 1, D) = 1.0; + obsprob(4, 2, d) = 1.0; + + Oargs = {'CPT', obsprob}; +else + Osize = 2; + mu = zeros(2, 4, 2); + noise = 0; + scale = 10; + for q3=1:2 + mu(:, 1, q3) = scale*[1;0] + noise*rand(2,1); + end + for q3=1:2 + mu(:, 2, q3) = scale*[0;-1] + noise*rand(2,1); + end + for q3=1:2 + mu(:, 3, q3) = scale*[-1;0] + noise*rand(2,1); + end + for q3=1:2 + mu(:, 4, q3) = scale*[0;1] + noise*rand(2,1); + end + Sigma = repmat(reshape(0.01*eye(2), [2 2 1 1 ]), [1 1 4 2]); + Oargs = {'mean', mu, 'cov', Sigma}; +end + +bnet = mk_hhmm('Qsizes', Qsizes, 'Osize', Osize', 'discrete_obs', discrete_obs, ... + 'Oargs', Oargs, 'Ops', Qnodes(2:3), ... + 'startprob', startprob, 'transprob', transprob, 'termprob', termprob); + +if discrete_obs + Tmax = 30; +else + Tmax = 200; +end +usecell = ~discrete_obs; +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +Qnodes = [Q1 Q2 Q3]; Fnodes = [F2 F3]; + +for seqi=1:3 + evidence = sample_dbn(bnet, Tmax, usecell, 'stop_sampling_F2'); + T = size(evidence, 2) + if discrete_obs + pretty_print_hhmm_parse(evidence, Qnodes, Fnodes, Onode, chars); + else + pos = zeros(2,T+1); + delta = cell2num(evidence(Onode,:)); + clf + hold on + cols = {'r', 'g', 'k', 'b'}; + boundary = cell2num(evidence(F3,:))-1; + coli = 1; + for t=2:T+1 + pos(:,t) = pos(:,t-1) + delta(:,t-1); + plot(pos(1,t), pos(2,t), sprintf('%c.', cols{coli})); + if boundary(t-1) + coli = coli + 1; + coli = mod(coli-1, length(cols)) + 1; + end + end + %plot(pos(1,:), pos(2,:), '.') + %pretty_print_hhmm_parse(evidence, Qnodes, Fnodes, Onode, []); + pause + end +end + +eclass = bnet.equiv_class; +S=struct(bnet.CPD{eclass(Q2,2)}); + + + + + + + diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m new file mode 100644 index 00000000..9790221c --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/get_square_data.m @@ -0,0 +1,70 @@ +% Let the user draw a square with the mouse, +% and then click on the corners to do a manual segmentation + +ss = 6; +Q1 = 1; Q2 = 2; Q3 = 3; obsvel = 6; +CLOCKWISE = 1; ANTICLOCK = 2; +LR = 1; UD = 2; RL = 3; DU = 4; + +% repeat this block manually incrementing the sequence number +% and setting ori. +% (since I don't know how to call getmouse as a call-return function). +seq = 4; +%ori = CLOCKWISE +ori = ANTICLOCK; +clear xpos ypos +getmouse +% end block + +% manual segmentation with the mouse +startseg(1) = 1; +for i=2:4 + fprintf('click on start of segment %d\n', i); + [x,y] = ginput(1); + plot(x,y,'ro') + d = dist2([xpos; ypos]', [x y]); + startseg(i) = argmin(d); +end + +% plot corners in green +%ti = first point in (i+1)st segment +t1 = startseg(1); t2 = startseg(2); t3 = startseg(3); t4 = startseg(4); +plot(xpos(t2), ypos(t2), 'g*') +plot(xpos(t3), ypos(t3), 'g*') +plot(xpos(t4), ypos(t4), 'g*') + + +xvel = xpos(2:end) - xpos(1:end-1); +yvel = ypos(2:end) - ypos(1:end-1); +speed = [xvel(:)'; yvel(:)']; +pos_data{seq} = [xpos(:)'; ypos(:)']; +vel_data{seq} = [xvel(:)'; yvel(:)']; +T = length(xvel); +Q1label{seq} = num2cell(repmat(ori, 1, T)); +Q2label{seq} = zeros(1, T); +if ori == CLOCKWISE + Q2label{seq}(t1:t2) = LR; + Q2label{seq}(t2+1:t3) = UD; + Q2label{seq}(t3+1:t4) = RL; + Q2label{seq}(t4+1:T) = DU; +else + Q2label{seq}(t1:t2) = RL; + Q2label{seq}(t2+1:t3) = UD; + Q2label{seq}(t3+1:t4) = LR; + Q2label{seq}(t4+1:T) = DU; +end + +% pos_data{seq}(:,t), vel_data{seq}(:,t) Q1label{seq}(t) Q2label{seq}(t) +save 'square4' pos_data vel_data Q1label Q2label + +nseq = 4; +cases = cell(1,nseq); +for seq=1:nseq + T = size(vel_data{seq},2); + ev = cell(ss,T); + ev(obsvel,:) = num2cell(vel_data{seq},1); + ev(Q1,:) = Q1label{seq}; + ev(Q2,:) = num2cell(Q2label{seq}); + cases{seq} = ev; +end +save 'square4_cases' cases diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/hhmm_inference.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/hhmm_inference.m new file mode 100644 index 00000000..c3bc8441 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/hhmm_inference.m @@ -0,0 +1,13 @@ +bnet = mk_square_hhmm(1, 1); + +engine = {}; +engine{end+1} = hmm_inf_engine(bnet); +engine{end+1} = smoother_engine(jtree_2TBN_inf_engine(bnet)); + +exact = 1:length(engine); +filter = 0; +single = 0; +maximize = 0; +T = 4; + +[err, inf_time, engine] = cmp_inference(bnet, engine, exact, T, filter, single, maximize); diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/is_F2_true_D3.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/is_F2_true_D3.m new file mode 100644 index 00000000..38d0b6e8 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/is_F2_true_D3.m @@ -0,0 +1,12 @@ +function stop = is_F2_true_D3(vals) +% function stop = is_F2_true_D3(vals) +% +% If vals(F2)=2 then level 2 has finished, so we return stop=1 +% to stop sample_dbn. Otherwise we return stop=0. +% We assume this is for a D=3 level HHMM. + +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +stop = 0; +if (iscell(vals) & vals{F2}==2) | (~iscell(vals) & vals(F2)==2) + stop = 1; +end diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/learn_square_hhmm_cts.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/learn_square_hhmm_cts.m new file mode 100644 index 00000000..77bdaec3 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/learn_square_hhmm_cts.m @@ -0,0 +1,152 @@ +% Try to learn a 3 level HHMM similar to mk_square_hhmm +% from hand-drawn squares. + +% Because startprob should be shared for t=1:T, +% but in the DBN is shared for t=2:T, we train using a single long sequence. + +discrete_obs = 0; +supervised = 1; +obs_finalF2 = 0; +% It is not possible to observe F2 if we learn +% because the update_ess method for hhmmF_CPD and hhmmQ_CPD assume +% the F nodes are always hidden (for speed). +% However, for generating, we might want to set the final F2=true +% to force all subroutines to finish. + +seed = 1; +rand('state', seed); +randn('state', seed); + +bnet = mk_square_hhmm(discrete_obs, 0); + +ss = 6; +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +Qnodes = [Q1 Q2 Q3]; Fnodes = [F2 F3]; +Qsizes = [2 4 1]; + +if supervised + bnet.observed = [Q1 Q2 Onode]; +else + bnet.observed = [Onode]; +end + +if obs_finalF2 + engine = jtree_dbn_inf_engine(bnet); + % can't use ndx version because sometimes F2 is hidden, sometimes observed + error('can''t observe F when learning') +else + if supervised + engine = jtree_ndx_dbn_inf_engine(bnet); + else + engine = jtree_hmm_inf_engine(bnet); + end +end + +load 'square4_cases' % cases{seq}{i,t} for i=1:ss +%plot_square_hhmm(cases{1}) +%long_seq = cat(2, cases{:}); +train_cases = cases(1:2); +long_seq = cat(2, train_cases{:}); +if ~supervised + T = size(long_seq,2); + for t=1:T + long_seq{Q1,t} = []; + long_seq{Q2,t} = []; + end +end +[bnet2, LL, engine2] = learn_params_dbn_em(engine, {long_seq}, 'max_iter', 2); + +eclass = bnet2.equiv_class; +CPDO=struct(bnet2.CPD{eclass(Onode,1)}); +mu = CPDO.mean; +Sigma = CPDO.cov; +CPDO_full = CPDO; + +% force diagonal covs after training +for k=1:size(Sigma,3) + Sigma(:,:,k) = diag(diag(Sigma(:,:,k))); +end +bnet2.CPD{6} = set_fields(bnet.CPD{6}, 'cov', Sigma); + +if 0 + % visualize each model by concatenating means for each model for nsteps in a row + nsteps = 5; + ev = cell(ss, nsteps*prod(Qsizes(2:3))); + t = 1; + for q2=1:Qsizes(2) + for q3=1:Qsizes(3) + for i=1:nsteps + ev{Onode,t} = mu(:,q2,q3); + ev{Q2,t} = q2; + t = t + 1; + end + end + end + plot_square_hhmm(ev) +end + +% bnet3 is the same as the learned model, except we will use it in testing mode +if supervised + bnet3 = bnet2; + bnet3.observed = [Onode]; + engine3 = hmm_inf_engine(bnet3); + %engine3 = jtree_ndx_dbn_inf_engine(bnet3); +else + bnet3 = bnet2; + engine3 = engine2; +end + +if 0 + % segment whole sequence + mpe = calc_mpe_dbn(engine3, long_seq); + pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, []); +end + +% segment each sequence +test_cases = cases(3:4); +for i=1:2 + ev = test_cases{i}; + T = size(ev, 2); + for t=1:T + ev{Q1,t} = []; + ev{Q2,t} = []; + end + %mpe = calc_mpe_dbn(engine3, ev); + mpe = find_mpe(engine3, ev) + subplot(1,2,i) + plot_square_hhmm(mpe) + %pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, []); + q1s = cell2num(mpe(Q1,:)); + h = hist(q1s, 1:Qsizes(1)); + map_q1 = argmax(h); + str = sprintf('test seq %d is of type %d\n', i, map_q1); + title(str) +end + + +if 0 +% Estimate gotten by couting transitions in the labelled data +% Note that a self transition shouldnt count if F2=off. +Q2ev = cell2num(ev(Q2,:)); +Q2a = Q2ev(1:end-1); +Q2b = Q2ev(2:end); +counts = compute_counts([Q2a; Q2b], [4 4]); +end + +eclass = bnet2.equiv_class; +CPDQ1=struct(bnet2.CPD{eclass(Q1,2)}); +CPDQ2=struct(bnet2.CPD{eclass(Q2,2)}); +CPDQ3=struct(bnet2.CPD{eclass(Q3,2)}); +CPDF2=struct(bnet2.CPD{eclass(F2,1)}); +CPDF3=struct(bnet2.CPD{eclass(F3,1)}); + + +A=add_hhmm_end_state(CPDQ2.transprob, CPDF2.termprob(:,:,2)); +squeeze(A(:,1,:)); +CPDQ2.startprob; + +if 0 +S=struct(CPDF2.sub_CPD_term); +S.nsamples +reshape(S.counts, [2 4 2]) +end diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/learn_square_hhmm_discrete.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/learn_square_hhmm_discrete.m new file mode 100644 index 00000000..3110ae5e --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/learn_square_hhmm_discrete.m @@ -0,0 +1,171 @@ +% Try to learn a 3 level HHMM similar to mk_square_hhmm +% from synthetic discrete sequences + + +discrete_obs = 1; +supervised = 0; +obs_finalF2 = 0; + +seed = 1; +rand('state', seed); +randn('state', seed); + +bnet_init = mk_square_hhmm(discrete_obs, 0); + +ss = 6; +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +Qnodes = [Q1 Q2 Q3]; Fnodes = [F2 F3]; + +if supervised + bnet_init.observed = [Q1 Q2 Onode]; +else + bnet_init.observed = [Onode]; +end + +if obs_finalF2 + engine_init = jtree_dbn_inf_engine(bnet_init); + % can't use ndx version because sometimes F2 is hidden, sometimes observed + error('can''t observe F when learning') + % It is not possible to observe F2 if we learn + % because the update_ess method for hhmmF_CPD and hhmmQ_CPD assume + % the F nodes are always hidden (for speed). + % However, for generating, we might want to set the final F2=true + % to force all subroutines to finish. +else + if supervised + engine_init = jtree_ndx_dbn_inf_engine(bnet_init); + else + engine_init = hmm_inf_engine(bnet_init); + end +end + +% generate some synthetic data (easier to debug) +chars = ['L', 'l', 'U', 'u', 'R', 'r', 'D', 'd']; +L=find(chars=='L'); l=find(chars=='l'); +U=find(chars=='U'); u=find(chars=='u'); +R=find(chars=='R'); r=find(chars=='r'); +D=find(chars=='D'); d=find(chars=='d'); + +cases = {}; + +T = 8; +ev = cell(ss, T); +ev(Onode,:) = num2cell([L l U u R r D d]); +if supervised + ev(Q1,:) = num2cell(1*ones(1,T)); + ev(Q2,:) = num2cell( [1 1 2 2 3 3 4 4]); +end +cases{1} = ev; +cases{3} = ev; + +T = 8; +ev = cell(ss, T); +%we start with R then r, even though we are running the model 'backwards'! +ev(Onode,:) = num2cell([R r U u L l D d]); + +if supervised + ev(Q1,:) = num2cell(2*ones(1,T)); + ev(Q2,:) = num2cell( [3 3 2 2 1 1 4 4]); +end + +cases{2} = ev; +cases{4} = ev; + +if obs_finalF2 + for i=1:length(cases) + T = size(cases{i},2); + cases{i}(F2,T)={2}; % force F2 to be finished at end of seq + end +end + + +% startprob should be shared for t=1:T, +% but in the DBN it is shared for t=2:T, +% so we train using a single long sequence. +long_seq = cat(2, cases{:}); +[bnet_learned, LL, engine_learned] = ... + learn_params_dbn_em(engine_init, {long_seq}, 'max_iter', 200); + +% figure out which subsequence each model is responsible for +mpe = calc_mpe_dbn(engine_learned, long_seq); +pretty_print_hhmm_parse(mpe, Qnodes, Fnodes, Onode, chars); + + +% The "true" segmentation of the training sequence is +% Q1: 1 2 +% O: L l U u R r D d | R r U u L l D d | etc. +% +% When we learn in a supervised fashion, we recover the "truth". + +% When we learn in an unsupervised fashion with seed=1, we get +% Q1: 2 1 +% O: L l U u R r D d R r | U u L l D d | etc. +% +% This means for model 1: +% starts in state 2 +% transitions 2->1, 1->4, 4->e, 3->2 +% +% For model 2, +% starts in state 1 +% transitions 1->2, 2->3, 3->4 or e, 4->3 + +% examine the params +eclass = bnet_learned.equiv_class; +CPDQ1=struct(bnet_learned.CPD{eclass(Q1,2)}); +CPDQ2=struct(bnet_learned.CPD{eclass(Q2,2)}); +CPDQ3=struct(bnet_learned.CPD{eclass(Q3,2)}); +CPDF2=struct(bnet_learned.CPD{eclass(F2,1)}); +CPDF3=struct(bnet_learned.CPD{eclass(F3,1)}); +CPDO=struct(bnet_learned.CPD{eclass(Onode,1)}); + +A_learned =add_hhmm_end_state(CPDQ2.transprob, CPDF2.termprob(:,:,2)); +squeeze(A_learned(:,1,:)) +squeeze(A_learned(:,2,:)) + + +% Does the "true" model have higher likelihood than the learned one? +% i.e., Does the unsupervised method learn the wrong model because +% we have the wrong cost fn, or because of local minima? + +bnet_true = mk_square_hhmm(discrete_obs,1); + +% examine the params +eclass = bnet_learned.equiv_class; +CPDQ1_true=struct(bnet_true.CPD{eclass(Q1,2)}); +CPDQ2_true=struct(bnet_true.CPD{eclass(Q2,2)}); +CPDQ3_true=struct(bnet_true.CPD{eclass(Q3,2)}); +CPDF2_true=struct(bnet_true.CPD{eclass(F2,1)}); +CPDF3_true=struct(bnet_true.CPD{eclass(F3,1)}); + +A_true =add_hhmm_end_state(CPDQ2_true.transprob, CPDF2_true.termprob(:,:,2)); +squeeze(A_true(:,1,:)) + + +if supervised + engine_true = jtree_ndx_dbn_inf_engine(bnet_true); +else + engine_true = hmm_inf_engine(bnet_true); +end + +%[engine_learned, ll_learned] = enter_evidence(engine_learned, long_seq); +%[engine_true, ll_true] = enter_evidence(engine_true, long_seq); +[engine_learned, ll_learned] = enter_evidence(engine_learned, cases{2}); +[engine_true, ll_true] = enter_evidence(engine_true, cases{2}); +ll_learned +ll_true + + +% remove concatentation artefacts +ll_learned = 0; +ll_true = 0; +for m=1:length(cases) + [engine_learned, ll_learned_tmp] = enter_evidence(engine_learned, cases{m}); + [engine_true, ll_true_tmp] = enter_evidence(engine_true, cases{m}); + ll_learned = ll_learned + ll_learned_tmp; + ll_true = ll_true + ll_true_tmp; +end +ll_learned +ll_true + +% In both cases, ll_learned >> ll_true +% which shows we are using the wrong cost function! diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/mk_square_hhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/mk_square_hhmm.m new file mode 100644 index 00000000..41cfc539 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/mk_square_hhmm.m @@ -0,0 +1,180 @@ +function bnet = mk_square_hhmm(discrete_obs, true_params, topright) + +% Make a 3 level HHMM described by the following grammar +% +% Square -> CLK | CCK % clockwise or counterclockwise +% CLK -> LR UD RL DU start on top left (1 2 3 4) +% CCK -> RL UD LR DU if start at top right (3 2 1 4) +% CCK -> UD LR DU RL if start at top left (2 1 4 3) +% +% LR = left-right, UD = up-down, RL = right-left, DU = down-up +% LR, UD, RL, DU are sub HMMs. +% +% For discrete observations, the subHMMs are 2-state left-right. +% LR emits L then l, etc. +% +% For cts observations, the subHMMs are 1 state. +% LR emits a vector in the -> direction, with a little noise. +% Since there is no constraint that we remain in the LR state as long as the RL state, +% the sides of the square might have different lengths, +% so the result is not really a square! +% +% If true_params = 0, we use random parameters at the top 2 levels +% (ready for learning). At the bottom level, we use noisy versions +% of the "true" observations. +% +% If topright=1, counter-clockwise starts at top right, not top left +% This example was inspired by Ivanov and Bobick. + +if nargin < 3, topright = 1; end + +if 1 % discrete_obs + Qsizes = [2 4 2]; +else + Qsizes = [2 4 1]; +end + +D = 3; +Qnodes = 1:D; +startprob = cell(1,D); +transprob = cell(1,D); +termprob = cell(1,D); + +% LEVEL 1 + +startprob{1} = 'unif'; +transprob{1} = 'unif'; + +% LEVEL 2 + +if true_params + startprob{2} = zeros(2, 4); + startprob{2}(1, :) = [1 0 0 0]; + if topright + startprob{2}(2, :) = [0 0 1 0]; + else + startprob{2}(2, :) = [0 1 0 0]; + end + + transprob{2} = zeros(4, 2, 4); + + transprob{2}(:,1,:) = [0 1 0 0 + 0 0 1 0 + 0 0 0 1 + 0 0 0 1]; % 4->e + if topright + transprob{2}(:,2,:) = [0 0 0 1 + 1 0 0 0 + 0 1 0 0 + 0 0 0 1]; % 4->e + else + transprob{2}(:,2,:) = [0 0 0 1 + 1 0 0 0 + 0 0 1 0 % 3->e + 0 0 1 0]; + end + + %termprob{2} = 'rightstop'; + termprob{2} = zeros(2,4); + pfin = 0.8; + termprob{2}(1,:) = [0 0 0 pfin]; % finish in state 4 (DU) + if topright + termprob{2}(2,:) = [0 0 0 pfin]; + else + termprob{2}(2,:) = [0 0 pfin 0]; % finish in state 3 (RL) + end +else + % In the unsupervised case, it is essential that we break symmetry + % in the initial param estimates. + %startprob{2} = 'unif'; + %transprob{2} = 'unif'; + %termprob{2} = 'unif'; + startprob{2} = 'rnd'; + transprob{2} = 'rnd'; + termprob{2} = 'rnd'; +end + +% LEVEL 3 + +if 1 | true_params + startprob{3} = 'leftstart'; + transprob{3} = 'leftright'; + termprob{3} = 'rightstop'; +else + % If we want to be able to run a base-level model backwards... + startprob{3} = 'rnd'; + transprob{3} = 'rnd'; + termprob{3} = 'rnd'; +end + + +% OBS LEVEl + +if discrete_obs + % Initialise observations of lowest level primitives in a way which we can interpret + chars = ['L', 'l', 'U', 'u', 'R', 'r', 'D', 'd']; + L=find(chars=='L'); l=find(chars=='l'); + U=find(chars=='U'); u=find(chars=='u'); + R=find(chars=='R'); r=find(chars=='r'); + D=find(chars=='D'); d=find(chars=='d'); + Osize = length(chars); + + if true_params + p = 1; % makes each state fully observed + else + p = 0.9; + end + + obsprob = (1-p)*ones([4 2 Osize]); + % Q2 Q3 O + obsprob(1, 1, L) = p; + obsprob(1, 2, l) = p; + obsprob(2, 1, U) = p; + obsprob(2, 2, u) = p; + obsprob(3, 1, R) = p; + obsprob(3, 2, r) = p; + obsprob(4, 1, D) = p; + obsprob(4, 2, d) = p; + obsprob = mk_stochastic(obsprob); + Oargs = {'CPT', obsprob}; +else + % Initialise means of lowest level primitives in a way which we can interpret + % These means are little vectors in the east, south, west, north directions. + % (left-right=east, up-down=south, right-left=west, down-up=north) + Osize = 2; + mu = zeros(2, Qsizes(2), Qsizes(3)); + scale = 3; + if true_params + noise = 0; + else + noise = 0.5*scale; + end + for q3=1:Qsizes(3) + mu(:, 1, q3) = scale*[1;0] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 2, q3) = scale*[0;-1] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 3, q3) = scale*[-1;0] + noise*rand(2,1); + end + for q3=1:Qsizes(3) + mu(:, 4, q3) = scale*[0;1] + noise*rand(2,1); + end + Sigma = repmat(reshape(scale*eye(2), [2 2 1 1 ]), [1 1 Qsizes(2) Qsizes(3)]); + Oargs = {'mean', mu, 'cov', Sigma, 'cov_type', 'diag'}; +end + +if discrete_obs + selfprob = 0.5; +else + selfprob = 0.95; + % If less than this, it won't look like a square + % because it doesn't spend enough time in each state + % Unfortunately, the variance on durations (lengths of each side) + % is very large +end +bnet = mk_hhmm('Qsizes', Qsizes, 'Osize', Osize', 'discrete_obs', discrete_obs, ... + 'Oargs', Oargs, 'Ops', Qnodes(2:3), 'selfprob', selfprob, ... + 'startprob', startprob, 'transprob', transprob, 'termprob', termprob); + diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/plot_square_hhmm.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/plot_square_hhmm.m new file mode 100644 index 00000000..e61e5669 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/plot_square_hhmm.m @@ -0,0 +1,27 @@ +function plot_square_hhmm(ev) +% Plot the square shape implicit in the evidence. +% ev{i,t} is the value of node i in slice t. +% The observed node contains a velocity (delta increment), which is converted +% into a position. +% The Q2 node specifies which model is used, and hence which color +% to use: 1=red, 2=green, 3=blue, 4=black. + +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; + +delta = cell2num(ev(Onode,:)); % delta(:,t) +Q2label = cell2num(ev(Q2,:)); + +T = size(delta, 2); +pos = zeros(2,T+1); +hold on +cols = {'r', 'g', 'b', 'k'}; +for t=2:T+1 + pos(:,t) = pos(:,t-1) + delta(:,t-1); + plot(pos(1,t), pos(2,t), sprintf('%c.', cols{Q2label(t-1)})); + if (t==2) + text(pos(1,t-1),pos(2,t-1),sprintf('%d',t)) + elseif (mod(t,20)==0) + text(pos(1,t),pos(2,t),sprintf('%d',t)) + end +end + diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/sample_square_hhmm_cts.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/sample_square_hhmm_cts.m new file mode 100644 index 00000000..3ab2abb5 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/sample_square_hhmm_cts.m @@ -0,0 +1,20 @@ +% Generate samples from the HHMM with the true params. + +seed = 1; +rand('state', seed); +randn('state', seed); + +discrete_obs = 0; + +bnet = mk_square_hhmm(discrete_obs, 1); +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +Qnodes = [Q1 Q2 Q3]; Fnodes = [F2 F3]; + +for seqi=1:1 + evidence = sample_dbn(bnet, 'stop_test', 'is_F2_true_D3'); + clf + plot_square_hhmm(evidence); + %pretty_print_hhmm_parse(evidence, Qnodes, Fnodes, Onode, []); + fprintf('sequence %d has length %d; press key to continue\n', seqi, size(evidence,2)) + pause +end diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/sample_square_hhmm_discrete.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/sample_square_hhmm_discrete.m new file mode 100644 index 00000000..20279899 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/sample_square_hhmm_discrete.m @@ -0,0 +1,20 @@ +% Generate samples from the HHMM with the true params. + +seed = 0; +rand('state', seed); +randn('state', seed); + +discrete_obs = 1; + +bnet = mk_square_hhmm(discrete_obs, 1); + +Tmax = 30; +Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6; +Qnodes = [Q1 Q2 Q3]; Fnodes = [F2 F3]; +chars = ['L', 'l', 'U', 'u', 'R', 'r', 'D', 'd']; + +for seqi=1:3 + evidence = cell2num(sample_dbn(bnet, 'stop_test', 'is_F2_true_D3')); + T = size(evidence, 2) + pretty_print_hhmm_parse(evidence, Qnodes, Fnodes, Onode, chars); +end diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/square4.mat b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/square4.mat new file mode 100644 index 00000000..cda0585b --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/square4.mat Binary files differdiff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/square4_cases.mat b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/square4_cases.mat new file mode 100644 index 00000000..788c3239 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/square4_cases.mat Binary files differdiff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/test_square_fig.m b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/test_square_fig.m new file mode 100644 index 00000000..e983af14 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/test_square_fig.m @@ -0,0 +1,1310 @@ +function fig = test_square_fig() +% This is the machine-generated representation of a Handle Graphics object +% and its children. Note that handle values may change when these objects +% are re-created. This may cause problems with any callbacks written to +% depend on the value of the handle at the time the object was saved. +% +% To reopen this object, just type the name of the M-file at the MATLAB +% prompt. The M-file and its associated MAT-file must be on your path. + +load test_square_fig + +h0 = figure('Color',[0.8 0.8 0.8], ... + 'Colormap',mat0, ... + 'PointerShapeCData',mat1, ... + 'Position',[540 374 476 292]); +h1 = axes('Parent',h0, ... + 'CameraUpVector',[0 1 0], ... + 'Color',[1 1 1], ... + 'ColorOrder',mat2, ... + 'NextPlot','add', ... + 'Position',[0.13 0.11 0.3270231213872832 0.8149999999999998], ... + 'XColor',[0 0 0], ... + 'XLim',[-10 50], ... + 'XLimMode','manual', ... + 'YColor',[0 0 0], ... + 'YLim',[-60 10], ... + 'YLimMode','manual', ... + 'ZColor',[0 0 0]); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',0.4608294930875587, ... + 'YData',0.2923976608187218); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'String','2'); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',1.152073732718893, ... + 'YData',0.2923976608187218); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',2.995391705069125, ... + 'YData',0.8771929824561511); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',3.686635944700463, ... + 'YData',0.8771929824561511); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',6.451612903225808, ... + 'YData',0.8771929824561511); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',9.677419354838712, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',10.36866359447005, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',15.43778801843318, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',17.51152073732719, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',19.81566820276498, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',20.50691244239631, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',23.73271889400922, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',25.57603686635945, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',29.95391705069125, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',31.79723502304147, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',35.02304147465438, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',35.71428571428572, ... + 'YData',2.046783625730996); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',38.47926267281106, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',40.3225806451613, ... + 'YData',1.461988304093566); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[40.3225806451613 1.461988304093566 0], ... + 'String','20'); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',42.62672811059908, ... + 'YData',mat3); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',43.31797235023042, ... + 'YData',mat4); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',43.31797235023042, ... + 'YData',0.8771929824561511); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',43.54838709677419, ... + 'YData',0); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',43.77880184331798, ... + 'YData',-0.5847953216374293); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',44.47004608294931, ... + 'YData',-2.339181286549703); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',44.93087557603687, ... + 'YData',-4.385964912280699); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',46.7741935483871, ... + 'YData',-9.064327485380119); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.00460829493088, ... + 'YData',-10.81871345029239); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.69585253456221, ... + 'YData',mat5); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.69585253456221, ... + 'YData',-15.20467836257309); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-19.00584795321637); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-19.88304093567251); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-22.51461988304093); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-23.09941520467836); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-26.02339181286549); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-26.31578947368421); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-27.77777777777777); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-28.3625730994152); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.23502304147466, ... + 'YData',-30.99415204678362); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[47.23502304147466 -30.99415204678362 0], ... + 'String','40'); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.46543778801843, ... + 'YData',-31.57894736842105); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.46543778801843, ... + 'YData',-33.62573099415204); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.46543778801843, ... + 'YData',-34.50292397660818); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.46543778801843, ... + 'YData',-37.42690058479531); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.46543778801843, ... + 'YData',-38.01169590643274); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.00460829493088, ... + 'YData',-42.39766081871344); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.00460829493088, ... + 'YData',-42.98245614035087); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',47.00460829493088, ... + 'YData',-46.49122807017543); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',46.7741935483871, ... + 'YData',-46.78362573099415); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',46.54377880184332, ... + 'YData',-49.41520467836257); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',46.54377880184332, ... + 'YData',-49.70760233918128); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',45.85253456221199, ... + 'YData',-51.46198830409356); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',45.85253456221199, ... + 'YData',-51.75438596491227); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',44.93087557603687, ... + 'YData',-53.21637426900584); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',44.70046082949308, ... + 'YData',-53.21637426900584); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',44.00921658986175, ... + 'YData',-54.09356725146198); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',43.77880184331798, ... + 'YData',-54.38596491228069); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',41.93548387096774, ... + 'YData',-54.97076023391811); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',41.47465437788019, ... + 'YData',-55.26315789473683); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',39.1705069124424, ... + 'YData',-55.55555555555554); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[39.1705069124424 -55.55555555555554 0], ... + 'String','60'); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',38.94009216589862, ... + 'YData',-55.84795321637426); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',36.63594470046083, ... + 'YData',-55.55555555555554); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',36.17511520737327, ... + 'YData',-55.55555555555554); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',32.94930875576037, ... + 'YData',-54.97076023391811); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',32.48847926267281, ... + 'YData',-54.97076023391811); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',28.11059907834102, ... + 'YData',-53.80116959064326); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',27.64976958525346, ... + 'YData',-53.50877192982455); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',23.963133640553, ... + 'YData',-53.50877192982455); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',23.27188940092166, ... + 'YData',-53.50877192982455); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',19.5852534562212, ... + 'YData',-54.97076023391811); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',19.12442396313364, ... + 'YData',-54.97076023391811); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',mat6, ... + 'YData',-56.14035087719297); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',mat7, ... + 'YData',-56.14035087719297); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',9.907834101382491, ... + 'YData',-57.30994152046782); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',9.447004608294932, ... + 'YData',-57.30994152046782); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',6.221198156682029, ... + 'YData',-57.30994152046782); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',4.838709677419356, ... + 'YData',-56.7251461988304); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',2.764976958525345, ... + 'YData',-56.14035087719297); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',2.534562211981569, ... + 'YData',-56.14035087719297); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',0.9216589861751174, ... + 'YData',-53.80116959064327); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[0.9216589861751174 -53.80116959064327 0], ... + 'String','80'); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',0.6912442396313381, ... + 'YData',-53.21637426900584); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.152073732718893, ... + 'YData',-48.24561403508771); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.152073732718893, ... + 'YData',-47.953216374269); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.843317972350228, ... + 'YData',-44.73684210526315); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.843317972350228, ... + 'YData',-44.44444444444444); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-2.304147465437787, ... + 'YData',-39.76608187134502); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-2.764976958525345, ... + 'YData',-38.01169590643274); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-3.225806451612904, ... + 'YData',-30.99415204678362); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-3.225806451612904, ... + 'YData',-29.82456140350877); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-3.225806451612904, ... + 'YData',-24.85380116959064); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-3.225806451612904, ... + 'YData',-24.26900584795321); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-2.534562211981566, ... + 'YData',-17.5438596491228); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-2.304147465437787, ... + 'YData',-16.95906432748537); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.612903225806452, ... + 'YData',-11.98830409356725); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.612903225806452, ... + 'YData',-11.40350877192982); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',mat8, ... + 'YData',-8.47953216374269); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',mat9, ... + 'YData',-8.187134502923968); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.152073732718893, ... + 'YData',-5.263157894736835); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-1.152073732718893, ... + 'YData',-4.970760233918128); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.9216589861751139, ... + 'YData',-2.923976608187132); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[-0.9216589861751139 -2.923976608187132 0], ... + 'String','100'); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.9216589861751139, ... + 'YData',-2.631578947368411); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.6912442396313345, ... + 'YData',mat10); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.6912442396313345, ... + 'YData',-0.8771929824561369); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.6912442396313345, ... + 'YData',-0.5847953216374293); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'HandleVisibility','off', ... + 'HorizontalAlignment','center', ... + 'Position',[19.80645161290322 12.0675105485232 17.32050807568877], ... + 'VerticalAlignment','bottom'); +set(get(h2,'Parent'),'Title',h2); +h1 = axes('Parent',h0, ... + 'CameraUpVector',[0 1 0], ... + 'Color',[1 1 1], ... + 'ColorOrder',mat11, ... + 'NextPlot','add', ... + 'Position',[0.5779768786127169 0.11 0.3270231213872832 0.8149999999999998], ... + 'XColor',[0 0 0], ... + 'YColor',[0 0 0], ... + 'ZColor',[0 0 0]); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.4608294930875587, ... + 'YData',0); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'String','2'); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-2.764976958525345, ... + 'YData',-0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-3.456221198156683, ... + 'YData',-0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-7.834101382488477, ... + 'YData',-0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-11.52073732718894, ... + 'YData',-0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',mat12, ... + 'YData',-0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-19.35483870967742, ... + 'YData',0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-23.50230414746544, ... + 'YData',0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-24.88479262672811, ... + 'YData',0.8771929824561369); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-28.11059907834102, ... + 'YData',0.8771929824561369); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-29.49308755760369, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-31.10599078341014, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-32.02764976958525, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-33.17972350230414, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-33.6405529953917, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 1], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-34.7926267281106, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-35.02304147465438, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-35.48387096774194, ... + 'YData',1.461988304093566); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-35.71428571428572, ... + 'YData',1.461988304093566); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[-35.71428571428572 1.461988304093566 0], ... + 'String','20'); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.17511520737327, ... + 'YData',mat13); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',0.8771929824561369); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.63594470046083, ... + 'YData',0.2923976608187076); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.63594470046083, ... + 'YData',0); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.63594470046083, ... + 'YData',mat14); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',-2.339181286549703); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',-2.631578947368425); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',-4.67836257309942); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',-5.555555555555557); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',-8.187134502923982); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.40552995391705, ... + 'YData',-8.771929824561397); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.86635944700461, ... + 'YData',-13.15789473684211); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',mat15); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-16.08187134502924); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-17.54385964912281); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-18.12865497076023); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-19.88304093567251); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-20.17543859649123); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-21.92982456140351); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-22.22222222222222); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[-37.09677419354839 -22.22222222222222 0], ... + 'String','40'); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-23.09941520467836); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.09677419354839, ... + 'YData',-23.39181286549707); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-25.14619883040935); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-25.43859649122807); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-28.3625730994152); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.55760368663595, ... + 'YData',-28.94736842105263); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-31.87134502923976); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-32.16374269005848); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-34.7953216374269); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-35.38011695906432); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-38.88888888888889); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-39.76608187134503); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-43.27485380116958); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-43.5672514619883); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.78801843317973, ... + 'YData',-44.44444444444444); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.55760368663595, ... + 'YData',-45.32163742690058); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.55760368663595, ... + 'YData',-45.61403508771929); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-47.36842105263158); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-37.32718894009217, ... + 'YData',-47.95321637426901); +h2 = line('Parent',h1, ... + 'Color',[0 1 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.86635944700461, ... + 'YData',-49.70760233918129); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[-36.86635944700461 -49.70760233918129 0], ... + 'String','60'); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-36.86635944700461, ... + 'YData',-50); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-35.71428571428572, ... + 'YData',-50.29239766081872); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-35.25345622119816, ... + 'YData',-50.29239766081872); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-32.02764976958527, ... + 'YData',-50.29239766081872); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-31.33640552995393, ... + 'YData',-50.29239766081872); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-27.88018433179725, ... + 'YData',-50.58479532163743); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-27.41935483870969, ... + 'YData',-50.58479532163743); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-18.20276497695854, ... + 'YData',-50.58479532163743); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-16.82027649769586, ... + 'YData',-51.16959064327486); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-12.21198156682029, ... + 'YData',-50.58479532163743); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-11.52073732718895, ... + 'YData',-50.58479532163743); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-6.912442396313377, ... + 'YData',-51.16959064327486); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-5.069124423963142, ... + 'YData',-51.75438596491229); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',mat16, ... + 'YData',-52.046783625731); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',-0.9216589861751281, ... + 'YData',-52.33918128654972); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',0.2304147465437687, ... + 'YData',-52.33918128654972); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',0.4608294930875481, ... + 'YData',-52.33918128654972); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',2.304147465437776, ... + 'YData',-52.63157894736843); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',2.534562211981548, ... + 'YData',-52.63157894736843); +h2 = line('Parent',h1, ... + 'Color',[1 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',3.917050691244224, ... + 'YData',-52.63157894736843); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[3.917050691244224 -52.63157894736843 0], ... + 'String','80'); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',4.147465437788011, ... + 'YData',-52.63157894736843); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',4.147465437788011, ... + 'YData',-52.33918128654972); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.529953917050673, ... + 'YData',-46.19883040935674); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.990783410138231, ... + 'YData',-44.44444444444446); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',7.834101382488466, ... + 'YData',-28.0701754385965); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',8.294930875576025, ... + 'YData',-22.80701754385966); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',8.755760368663584, ... + 'YData',mat17); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',8.525345622119797, ... + 'YData',-14.9122807017544); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',7.373271889400908, ... + 'YData',-10.23391812865498); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',7.142857142857135, ... + 'YData',-9.94152046783627); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',6.221198156682018, ... + 'YData',-7.602339181286567); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',6.221198156682018, ... + 'YData',-7.309941520467845); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.760368663594459, ... + 'YData',-5.555555555555571); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.529953917050673, ... + 'YData',-5.555555555555571); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.2995391705069, ... + 'YData',-4.093567251462005); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.069124423963128, ... + 'YData',-2.631578947368439); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.069124423963128, ... + 'YData',-2.339181286549717); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.069124423963128, ... + 'YData',mat18); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',5.069124423963128, ... + 'YData',-1.169590643274873); +h2 = line('Parent',h1, ... + 'Color',[0 0 0], ... + 'LineStyle','none', ... + 'Marker','.', ... + 'XData',4.838709677419342, ... + 'YData',-0.2923976608187218); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'Position',[4.838709677419342 -0.2923976608187218 0], ... + 'String','100'); +h2 = text('Parent',h1, ... + 'Color',[0 0 0], ... + 'HandleVisibility','off', ... + 'HorizontalAlignment','center', ... + 'Position',[-10.38961038961038 12.0675105485232 17.32050807568877], ... + 'VerticalAlignment','bottom'); +set(get(h2,'Parent'),'Title',h2); +if nargout > 0, fig = h0; end diff --git a/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/test_square_fig.mat b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/test_square_fig.mat new file mode 100644 index 00000000..5b2b5f53 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/examples/dynamic/HHMM/Square/test_square_fig.mat Binary files differ |
