matthiasm@0: % TEST_FLST tests the fixed lag sparse transition Viterbi implementation matthiasm@0: matthiasm@0: addpath('misc') matthiasm@0: addpath('smoothiecore') matthiasm@0: addpath('flst') matthiasm@0: matthiasm@0: %% setup model matthiasm@0: matthiasm@0: mdl = hmm_dummy(); matthiasm@0: memory = 3; matthiasm@0: d = flstMakeData(mdl, memory); matthiasm@0: matthiasm@0: %% now make up some probabilites matthiasm@0: matthiasm@0: obsLik = [... matthiasm@0: [0.5, 0.5]; matthiasm@0: [0.8, 0.2]; matthiasm@0: [0.4, 0.6]; matthiasm@0: [0.8, 0.2]; matthiasm@0: [0.8, 0.2]; matthiasm@0: [0.2, 0.8]; matthiasm@0: [0.3, 0.7]; matthiasm@0: [0.9, 0.1]]'; matthiasm@0: matthiasm@0: nFrame = size(obsLik,2); matthiasm@0: matthiasm@0: matthiasm@0: for iFrame = 1:nFrame-1 matthiasm@0: d = flstViterbiUpdate(obsLik(:,iFrame), d); matthiasm@0: end matthiasm@0: d = flstViterbiUpdate(obsLik(:,iFrame), d, 1); matthiasm@0: e = d; matthiasm@0: d = flstMakeData(mdl, memory); matthiasm@0: disp(e) matthiasm@0: matthiasm@0: %% test matthiasm@0: matthiasm@0: if all((e.path-[1 1 1 1 1 2 2 2])==0) matthiasm@0: fprintf(1, 'Test ok.\n'); matthiasm@0: else matthiasm@0: warning('Test has detected an error.') matthiasm@0: end