Daniel@0: function marginal = marginal_nodes(engine, nodes, t) Daniel@0: % MARGINAL_NODES Compute the marginal on the specified query nodes (ff) Daniel@0: % marginal = marginal_nodes(engine, i, t) Daniel@0: % returns Pr(X(i,t) | Y(1:T)), where X(i,t) is the i'th node in the t'th slice. Daniel@0: % If enter_evidence used filtering instead of smoothing, this will return Pr(X(i,t) | Y(1:t)). Daniel@0: Daniel@0: if nargin < 3, t = 1; end Daniel@0: assert(length(nodes)==1); Daniel@0: i = nodes(end); Daniel@0: if myismember(i, engine.hnodes) Daniel@0: marginal = pot_to_marginal(engine.marginals{i,t}); Daniel@0: else Daniel@0: marginal = pot_to_marginal(dpot(i, 1, 1)); % observed Daniel@0: end Daniel@0: Daniel@0: bnet = bnet_from_engine(engine); Daniel@0: ss = length(bnet.intra); Daniel@0: % we convert the domain to the unrolled numbering system Daniel@0: % so that update_ess extracts the right evidence. Daniel@0: marginal.domain = nodes+(t-1)*ss;