diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/BNT/potentials/@scgpot/recursive_combine_pots.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/BNT/potentials/@scgpot/recursive_combine_pots.m')
| -rw-r--r-- | sourcecodes/bnt-master/BNT/potentials/@scgpot/recursive_combine_pots.m | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgpot/recursive_combine_pots.m b/sourcecodes/bnt-master/BNT/potentials/@scgpot/recursive_combine_pots.m new file mode 100644 index 00000000..27c04b75 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/potentials/@scgpot/recursive_combine_pots.m @@ -0,0 +1,40 @@ +function pot = recursive_combine_pots(pot1, pot2) +% RECURSIVE_COMBINE_POTS recursive combine two potentials +% pot = recursive_combine_pots(pot1, pot2) + +pot1 = reduce_pot(pot1); +pot2 = reduce_pot(pot2); +% Recursion is stopped, if recusive-combination is defined by direct combination, +% i.e. if the domain of one potential is disjoint from the head of the other. +if (isempty(myintersect(pot1.domain,pot2.cheaddom))|... + isempty(myintersect(pot1.cheaddom,pot2.domain))) + pot = direct_combine_pots(pot1,pot2); +else + % Test wether one of the set-differences is not empty + % as defined in Lauritzen99 "Stable Local Computation with Conditional Gaussian Distributions" + % on page 9 + D12 = mysetdiff(pot1.cheaddom, pot2.domain); + D21 = mysetdiff(pot2.cheaddom, pot1.domain); + if (isempty(D12) & isempty(D21)) + assert(0,'Recursive combination is not defined'); + end + + if ~isempty(D12) + % Calculate the complementary potential for the set + % D1\D12 as defined in Lauritzen 99, page 9 + keep = mysetdiff(pot1.domain,D12); + [margpot, comppot] = complement_pot(pot1,keep); + margpot = reduce_pot(margpot); + comppot = reduce_pot(comppot); + pot = direct_combine_pots( recursive_combine_pots(margpot, pot2), comppot); + elseif ~isempty(D21) + keep = mysetdiff(pot2.domain,D21); + [margpot, comppot] = complement_pot(pot2,D21); + margpot = reduce_pot(margpot); + comppot = reduce_pot(comppot); + pot = direct_combine_pots( recursive_combine_pots(pot1, margpot), comppot); + end +end + + + |
