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