Mercurial > hg > flst
annotate matlab/test_flst.m @ 1:4283604499f8 tip
added mini probability to delta (not sure if this is a good idea, but I did it)
author | matthiasm |
---|---|
date | Mon, 10 Nov 2014 19:38:49 +0000 |
parents | 1df4a6fb0d22 |
children |
rev | line source |
---|---|
matthiasm@0 | 1 % TEST_FLST tests the fixed lag sparse transition Viterbi implementation |
matthiasm@0 | 2 |
matthiasm@0 | 3 addpath('misc') |
matthiasm@0 | 4 addpath('smoothiecore') |
matthiasm@0 | 5 addpath('flst') |
matthiasm@0 | 6 |
matthiasm@0 | 7 %% setup model |
matthiasm@0 | 8 |
matthiasm@0 | 9 mdl = hmm_dummy(); |
matthiasm@0 | 10 memory = 3; |
matthiasm@0 | 11 d = flstMakeData(mdl, memory); |
matthiasm@0 | 12 |
matthiasm@0 | 13 %% now make up some probabilites |
matthiasm@0 | 14 |
matthiasm@0 | 15 obsLik = [... |
matthiasm@0 | 16 [0.5, 0.5]; |
matthiasm@0 | 17 [0.8, 0.2]; |
matthiasm@0 | 18 [0.4, 0.6]; |
matthiasm@0 | 19 [0.8, 0.2]; |
matthiasm@0 | 20 [0.8, 0.2]; |
matthiasm@0 | 21 [0.2, 0.8]; |
matthiasm@0 | 22 [0.3, 0.7]; |
matthiasm@0 | 23 [0.9, 0.1]]'; |
matthiasm@0 | 24 |
matthiasm@0 | 25 nFrame = size(obsLik,2); |
matthiasm@0 | 26 |
matthiasm@0 | 27 |
matthiasm@0 | 28 for iFrame = 1:nFrame-1 |
matthiasm@0 | 29 d = flstViterbiUpdate(obsLik(:,iFrame), d); |
matthiasm@0 | 30 end |
matthiasm@0 | 31 d = flstViterbiUpdate(obsLik(:,iFrame), d, 1); |
matthiasm@0 | 32 e = d; |
matthiasm@0 | 33 d = flstMakeData(mdl, memory); |
matthiasm@0 | 34 disp(e) |
matthiasm@0 | 35 |
matthiasm@0 | 36 %% test |
matthiasm@0 | 37 |
matthiasm@0 | 38 if all((e.path-[1 1 1 1 1 2 2 2])==0) |
matthiasm@0 | 39 fprintf(1, 'Test ok.\n'); |
matthiasm@0 | 40 else |
matthiasm@0 | 41 warning('Test has detected an error.') |
matthiasm@0 | 42 end |