wolffd@0: function mpe = find_mpe(engine, evidence) wolffd@0: % FIND_MPE Find the most probable explanation (Viterbi) wolffd@0: % mpe = enter_evidence(engine, evidence, ...) wolffd@0: % wolffd@0: % evidence{i,t} = [] if if X(i,t) is hidden, and otherwise contains its observed value (scalar or column vector) wolffd@0: % wolffd@0: wolffd@0: obslik = mk_hmm_obs_lik_matrix(engine, evidence); wolffd@0: path = viterbi_path(engine.startprob, engine.transprob, obslik); wolffd@0: bnet = bnet_from_engine(engine); wolffd@0: ns = bnet.node_sizes_slice; wolffd@0: ns(bnet.observed) = 1; wolffd@0: ass = ind2subv(ns, path); wolffd@0: mpe = num2cell(ass'); wolffd@0: mpe(bnet.observed,:) = evidence(bnet.observed,:); wolffd@0: