wolffd@0: function post = compute_posterior_dbn(bnet, state, i, n, strides, families, ... wolffd@0: CPT) wolffd@0: % COMPUTE_POSTERIOR wolffd@0: % wolffd@0: % post = compute_posterior(bnet, state, i, n, strides, families, wolffd@0: % cpts) wolffd@0: % wolffd@0: % Compute the posterior distribution on node X_i^n of a DBN, wolffd@0: % conditional on evidence in the cell array state wolffd@0: % wolffd@0: % strides is the cached result of compute_strides(bnet) wolffd@0: % families is the cached result of compute_families(bnet) wolffd@0: % cpt is the cached result of get_cpts(bnet) wolffd@0: % wolffd@0: % post is a one-dimensional table wolffd@0: wolffd@0: wolffd@0: wolffd@0: % First multiply in the cpt of the node itself wolffd@0: post = get_slice_dbn(bnet, state, i, n, i, n, strides, families, CPT); wolffd@0: post = post(:); wolffd@0: wolffd@0: % Then multiply in CPTs of children that are in this slice wolffd@0: for j = children(bnet.intra, i) wolffd@0: slice = get_slice_dbn(bnet, state, j, n, i, n, strides, families, CPT); wolffd@0: post = post.*slice(:); wolffd@0: end wolffd@0: wolffd@0: % Finally, if necessary, multiply in CPTs of children in the next wolffd@0: % slice wolffd@0: if (n < size(state,2)) wolffd@0: for j = children(bnet.inter, i) wolffd@0: slice = get_slice_dbn(bnet, state, j, n+1, i, n, strides, families, ... wolffd@0: CPT); wolffd@0: post = post.*slice(:); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: post = normalise(post); wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: wolffd@0: