comparison toolboxes/FullBNT-1.0.7/bnt/potentials/@scgpot/recursive_combine_pots.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 pot = recursive_combine_pots(pot1, pot2)
2 % RECURSIVE_COMBINE_POTS recursive combine two potentials
3 % pot = recursive_combine_pots(pot1, pot2)
4
5 pot1 = reduce_pot(pot1);
6 pot2 = reduce_pot(pot2);
7 % Recursion is stopped, if recusive-combination is defined by direct combination,
8 % i.e. if the domain of one potential is disjoint from the head of the other.
9 if (isempty(myintersect(pot1.domain,pot2.cheaddom))|...
10 isempty(myintersect(pot1.cheaddom,pot2.domain)))
11 pot = direct_combine_pots(pot1,pot2);
12 else
13 % Test wether one of the set-differences is not empty
14 % as defined in Lauritzen99 "Stable Local Computation with Conditional Gaussian Distributions"
15 % on page 9
16 D12 = mysetdiff(pot1.cheaddom, pot2.domain);
17 D21 = mysetdiff(pot2.cheaddom, pot1.domain);
18 if (isempty(D12) & isempty(D21))
19 assert(0,'Recursive combination is not defined');
20 end
21
22 if ~isempty(D12)
23 % Calculate the complementary potential for the set
24 % D1\D12 as defined in Lauritzen 99, page 9
25 keep = mysetdiff(pot1.domain,D12);
26 [margpot, comppot] = complement_pot(pot1,keep);
27 margpot = reduce_pot(margpot);
28 comppot = reduce_pot(comppot);
29 pot = direct_combine_pots( recursive_combine_pots(margpot, pot2), comppot);
30 elseif ~isempty(D21)
31 keep = mysetdiff(pot2.domain,D21);
32 [margpot, comppot] = complement_pot(pot2,D21);
33 margpot = reduce_pot(margpot);
34 comppot = reduce_pot(comppot);
35 pot = direct_combine_pots( recursive_combine_pots(pot1, margpot), comppot);
36 end
37 end
38
39
40