Mercurial > hg > camir-ismir2012
comparison toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@cbk_inf_engine/enter_evidence.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cc4b1211e677 |
---|---|
1 function [engine, loglik] = enter_evidence(engine, evidence, varargin) | |
2 % this is unchanged from bk_inf_engine. | |
3 % ENTER_EVIDENCE Add the specified evidence to the network (bk) | |
4 % [engine, loglik] = enter_evidence(engine, evidence, ...) | |
5 % | |
6 % evidence{i,t} = [] if if X(i,t) is hidden, and otherwise contains its observed value (scalar or column vector) | |
7 % | |
8 % The following optional arguments can be specified in the form of name/value pairs: | |
9 % [default value in brackets] | |
10 % | |
11 % maximize - if 1, does max-product instead of sum-product [0] | |
12 % filter - if 1, do filtering, else smoothing [0] | |
13 % | |
14 % e.g., engine = enter_evidence(engine, ev, 'maximize', 1) | |
15 | |
16 maximize = 0; | |
17 filter = 0; | |
18 | |
19 % parse optional params | |
20 args = varargin; | |
21 nargs = length(args); | |
22 if nargs > 0 | |
23 for i=1:2:nargs | |
24 switch args{i}, | |
25 case 'maximize', maximize = args{i+1}; | |
26 case 'filter', filter = args{i+1}; | |
27 otherwise, | |
28 error(['invalid argument name ' args{i}]); | |
29 end | |
30 end | |
31 end | |
32 | |
33 [ss T] = size(evidence); | |
34 engine.filter = filter; | |
35 engine.maximize = maximize; | |
36 engine.T = T; | |
37 | |
38 if maximize | |
39 error('BK does not yet support max propagation') | |
40 % because it calls enter_soft_evidence, not enter_evidence | |
41 end | |
42 | |
43 observed_bitv = ~isemptycell(evidence); | |
44 onodes = find(observed_bitv); | |
45 bnet = bnet_from_engine(engine); | |
46 pot_type = determine_pot_type(bnet, onodes); | |
47 CPDpot = convert_dbn_CPDs_to_pots(bnet, evidence, pot_type); | |
48 [engine.clpot, loglik] = enter_soft_evidence(engine, CPDpot, observed_bitv, pot_type, filter); |