wolffd@0: function [B,D,mu] = extract_params_from_gbn(bnet) wolffd@0: % Extract all the local parameters of each Gaussian node, and collect them into global matrices. wolffd@0: % [B,D,mu] = extract_params_from_gbn(bnet) wolffd@0: % wolffd@0: % B(i,j) is a block matrix that contains the transposed weight matrix from node i to node j. wolffd@0: % D(i,i) is a block matrix that contains the noise covariance matrix for node i. wolffd@0: % mu(i) is a block vector that contains the shifted noise mean for node i. wolffd@0: wolffd@0: % In Shachter's model, the mean of each node in the global gaussian is wolffd@0: % the same as the node's local unconditional mean. wolffd@0: % In Alag's model (which we use), the global mean gets shifted. wolffd@0: wolffd@0: wolffd@0: num_nodes = length(bnet.dag); wolffd@0: bs = bnet.node_sizes(:); % bs = block sizes wolffd@0: N = sum(bs); % num scalar nodes wolffd@0: wolffd@0: B = zeros(N,N); wolffd@0: D = zeros(N,N); wolffd@0: mu = zeros(N,1); wolffd@0: wolffd@0: for i=1:num_nodes % in topological order wolffd@0: ps = parents(bnet.dag, i); wolffd@0: e = bnet.equiv_class(i); wolffd@0: %[m, Sigma, weights] = extract_params_from_CPD(bnet.CPD{e}); wolffd@0: s = struct(bnet.CPD{e}); % violate privacy of object wolffd@0: m = s.mean; Sigma = s.cov; weights = s.weights; wolffd@0: if length(ps) == 0 wolffd@0: mu(block(i,bs)) = m; wolffd@0: else wolffd@0: mu(block(i,bs)) = m + weights * mu(block(ps,bs)); wolffd@0: end wolffd@0: B(block(ps,bs), block(i,bs)) = weights'; wolffd@0: D(block(i,bs), block(i,bs)) = Sigma; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: