wolffd@0: function [obs, hidden] = dhmm_sample_endstate(startprob, transmat, obsmat, endprob, numex) wolffd@0: % SAMPLE_DHMM Generate random sequences from an HMM with discrete outputs. wolffd@0: % function [obs, hidden] = sample_dhmm_endstate(startprob, transmat, obsmat, endprob, numex) wolffd@0: % wolffd@0: % We sample until we have have entered the end state wolffd@0: % obs{m} and hidden{m} are the m'th sequence wolffd@0: wolffd@0: hidden = cell(1,numex); wolffd@0: obs = cell(1,numex); wolffd@0: wolffd@0: for m=1:numex wolffd@0: hidden{m} = mc_sample_endstate(startprob, transmat, endprob); wolffd@0: T = length(hidden{m}); wolffd@0: obs{m} = zeros(1,T); wolffd@0: for t=1:T wolffd@0: h = hidden{m}(t); wolffd@0: obs{m}(t) = sample_discrete(obsmat(h,:)); wolffd@0: end wolffd@0: end