annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@gibbs_sampling_inf_engine/private/compute_posterior_dbn.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function post = compute_posterior_dbn(bnet, state, i, n, strides, families, ...
wolffd@0 2 CPT)
wolffd@0 3 % COMPUTE_POSTERIOR
wolffd@0 4 %
wolffd@0 5 % post = compute_posterior(bnet, state, i, n, strides, families,
wolffd@0 6 % cpts)
wolffd@0 7 %
wolffd@0 8 % Compute the posterior distribution on node X_i^n of a DBN,
wolffd@0 9 % conditional on evidence in the cell array state
wolffd@0 10 %
wolffd@0 11 % strides is the cached result of compute_strides(bnet)
wolffd@0 12 % families is the cached result of compute_families(bnet)
wolffd@0 13 % cpt is the cached result of get_cpts(bnet)
wolffd@0 14 %
wolffd@0 15 % post is a one-dimensional table
wolffd@0 16
wolffd@0 17
wolffd@0 18
wolffd@0 19 % First multiply in the cpt of the node itself
wolffd@0 20 post = get_slice_dbn(bnet, state, i, n, i, n, strides, families, CPT);
wolffd@0 21 post = post(:);
wolffd@0 22
wolffd@0 23 % Then multiply in CPTs of children that are in this slice
wolffd@0 24 for j = children(bnet.intra, i)
wolffd@0 25 slice = get_slice_dbn(bnet, state, j, n, i, n, strides, families, CPT);
wolffd@0 26 post = post.*slice(:);
wolffd@0 27 end
wolffd@0 28
wolffd@0 29 % Finally, if necessary, multiply in CPTs of children in the next
wolffd@0 30 % slice
wolffd@0 31 if (n < size(state,2))
wolffd@0 32 for j = children(bnet.inter, i)
wolffd@0 33 slice = get_slice_dbn(bnet, state, j, n+1, i, n, strides, families, ...
wolffd@0 34 CPT);
wolffd@0 35 post = post.*slice(:);
wolffd@0 36 end
wolffd@0 37 end
wolffd@0 38
wolffd@0 39 post = normalise(post);
wolffd@0 40
wolffd@0 41
wolffd@0 42
wolffd@0 43
wolffd@0 44
wolffd@0 45
wolffd@0 46
wolffd@0 47
wolffd@0 48
wolffd@0 49
wolffd@0 50
wolffd@0 51
wolffd@0 52
wolffd@0 53
wolffd@0 54
wolffd@0 55
wolffd@0 56
wolffd@0 57
wolffd@0 58
wolffd@0 59