comparison toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@kalman_inf_engine/private/extract_params_from_gbn.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 [B,D,mu] = extract_params_from_gbn(bnet)
2 % Extract all the local parameters of each Gaussian node, and collect them into global matrices.
3 % [B,D,mu] = extract_params_from_gbn(bnet)
4 %
5 % B(i,j) is a block matrix that contains the transposed weight matrix from node i to node j.
6 % D(i,i) is a block matrix that contains the noise covariance matrix for node i.
7 % mu(i) is a block vector that contains the shifted noise mean for node i.
8
9 % In Shachter's model, the mean of each node in the global gaussian is
10 % the same as the node's local unconditional mean.
11 % In Alag's model (which we use), the global mean gets shifted.
12
13
14 num_nodes = length(bnet.dag);
15 bs = bnet.node_sizes(:); % bs = block sizes
16 N = sum(bs); % num scalar nodes
17
18 B = zeros(N,N);
19 D = zeros(N,N);
20 mu = zeros(N,1);
21
22 for i=1:num_nodes % in topological order
23 ps = parents(bnet.dag, i);
24 e = bnet.equiv_class(i);
25 %[m, Sigma, weights] = extract_params_from_CPD(bnet.CPD{e});
26 s = struct(bnet.CPD{e}); % violate privacy of object
27 m = s.mean; Sigma = s.cov; weights = s.weights;
28 if length(ps) == 0
29 mu(block(i,bs)) = m;
30 else
31 mu(block(i,bs)) = m + weights * mu(block(ps,bs));
32 end
33 B(block(ps,bs), block(i,bs)) = weights';
34 D(block(i,bs), block(i,bs)) = Sigma;
35 end
36
37
38