comparison toolboxes/FullBNT-1.0.7/bnt/potentials/@cgpot/pot_to_marginal.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 m = pot_to_marginal(pot)
2 % POT_TO_MARGINAL Convert a cgpot to a marginal structure.
3 % m = pot_to_marginal(pot)
4
5 pot = cg_can_to_mom(pot);
6 m.domain = pot.domain;
7 n = pot.csize;
8 d = length(pot.mom);
9 if n==0
10 m.mu = [];
11 m.Sigma = [];
12 else
13 m.mu = zeros(n, d);
14 m.Sigma = zeros(n, n, d);
15 end
16 m.T = 0*myones(pot.dsizes);
17 for i=1:pot.dsize
18 s = struct(pot.mom{i}); % violate privacy of object
19 if n > 0
20 m.mu(:,i) = s.mu;
21 m.Sigma(:,:,i) = s.Sigma;
22 end
23 m.T(i) = exp(s.logp);
24 end
25 if isvectorBNT(m.T)
26 m.T = m.T(:)';
27 end