Daniel@0: function marginal = marginal_nodes(engine, nodes, t) Daniel@0: % MARGINAL_NODES Compute the marginal on the specified query nodes (kalman) Daniel@0: % marginal = marginal_nodes(engine, nodes, t) Daniel@0: % Daniel@0: % 't' specifies the time slice of the earliest node in 'nodes'. Daniel@0: % 'nodes' cannot span more than 2 time slices. Daniel@0: % Daniel@0: % Example: Daniel@0: % Consider a DBN with 2 nodes per slice. Daniel@0: % Then t=2, nodes=[1 3] refers to node 1 in slice 2 and node 1 in slice 3, Daniel@0: % i.e., nodes 3 and 5 in the unrolled network, Daniel@0: Daniel@0: if nargin < 3, t = 1; end Daniel@0: Daniel@0: bnet = bnet_from_engine(engine); Daniel@0: ss = length(bnet.intra); Daniel@0: if all(nodes <= ss) Daniel@0: bigpot = engine.one_slice_marginal{t}; Daniel@0: else Daniel@0: bigpot = engine.two_slice_marginal{t}; Daniel@0: end Daniel@0: Daniel@0: nodes = nodes + (t-1)*ss; Daniel@0: pot = marginalize_pot(bigpot, nodes); Daniel@0: marginal = pot_to_marginal(pot);