about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/potentials/@scgcpot
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/bnt-master/BNT/potentials/@scgcpot')
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Entries6
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Repository1
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Root1
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/marginalize_pot.m7
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/normalize_pot.m6
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/reduce_pot.m32
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/rescale_pot.m5
-rw-r--r--sourcecodes/bnt-master/BNT/potentials/@scgcpot/scgcpot.m49
8 files changed, 107 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Entries b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Entries
new file mode 100644
index 00000000..d5b4bd91
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Entries
@@ -0,0 +1,6 @@
+/marginalize_pot.m/1.1.1.1/Sun May 19 22:11:08 2002//
+/normalize_pot.m/1.1.1.1/Sun May 19 22:11:08 2002//
+/reduce_pot.m/1.1.1.1/Tue Mar 11 17:37:02 2003//
+/rescale_pot.m/1.1.1.1/Sun May 19 22:11:08 2002//
+/scgcpot.m/1.1.1.1/Sun May 19 22:11:08 2002//
+D
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Repository b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Repository
new file mode 100644
index 00000000..18dc4d80
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Repository
@@ -0,0 +1 @@
+FullBNT/BNT/potentials/@scgcpot
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Root b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Root
new file mode 100644
index 00000000..f3bd14a6
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/CVS/Root
@@ -0,0 +1 @@
+:ext:nsaunier@bnt.cvs.sourceforge.net:/cvsroot/bnt
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/marginalize_pot.m b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/marginalize_pot.m
new file mode 100644
index 00000000..c4ca9b68
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/marginalize_pot.m
@@ -0,0 +1,7 @@
+function smallpot = marginalize_pot(bigpot, keepdom, sumoverdom, nodesizes)
+% MARGINALIZE_POT Marginalize a mpot onto a smaller domain.
+% smallpot = marginalize_pot(bigpot, keep)
+
+keepsize = sum(nodesizes(keepdom));
+[A1, A2, B1, B2, C11, C12, C21, C22] = partition_matrix_vec_3(bigpot.A, bigpot.B, bigpot.C, keepdom, sumoverdom, nodesizes);
+smallpot = scgcpot(keepsize, bigpot.ctailsize, bigpot.p, A1, B1, C11);
\ No newline at end of file
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/normalize_pot.m b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/normalize_pot.m
new file mode 100644
index 00000000..8900c66e
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/normalize_pot.m
@@ -0,0 +1,6 @@
+function [pot, loglik] = normalize_pot(pot)
+% NORMALIZE_POT Convert the element of stable conditional gaussian potential Pr(X,E) into Pr(X|E) and return log Pr(E).
+% [pot, loglik] = normalize_pot(pot)
+
+loglik = log(pot.p);
+pot.p = 1;
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/reduce_pot.m b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/reduce_pot.m
new file mode 100644
index 00000000..466a7a72
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/reduce_pot.m
@@ -0,0 +1,32 @@
+function [reduced_pot,successful] = reduce(pot,tailnodes)
+% Executes the reduce operation defined in 
+% Stable Local Computation with Conditional Gaussian Distributions
+% Steffen L. Lauritzen
+% Frank Jensen
+% September 1999
+% The potential pot is reduced if B contains any zero columns 
+% The test are restricted to the positions in tailnodes.
+% Any columns successfully deleted are entered in the array successful
+
+if nargin < 2
+    tailnodes = 1:pot.ctailsize;
+end
+
+successful = [];
+
+% Look for all columns beeing equal to zero
+for i = tailnodes
+    if ~any(pot.B(:,i))
+        successful = [successful i]; 
+    end
+end
+
+remain = mysetdiff(1:pot.ctailsize,successful);
+
+% Erase the zero-columns and decrease the tailsize
+pot.B = pot.B(:,remain);
+pot.ctailsize = pot.ctailsize - length(successful);
+
+% Return the reduced potential
+reduced_pot = pot;
+  
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/rescale_pot.m b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/rescale_pot.m
new file mode 100644
index 00000000..996a6351
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/rescale_pot.m
@@ -0,0 +1,5 @@
+function pot = rescale_pot(pot, s)
+% RESCALE_POT Add a constant to the mpot scale factor.
+% pot = rescale_pot(pot, s)
+
+pot.p = pot.p*s;
diff --git a/sourcecodes/bnt-master/BNT/potentials/@scgcpot/scgcpot.m b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/scgcpot.m
new file mode 100644
index 00000000..6d53a16f
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/potentials/@scgcpot/scgcpot.m
@@ -0,0 +1,49 @@
+function pot = scgcpot(cheadsize, ctailsize, p, A, B, C)
+% SCGCPOT Make a base object of stable conditional gaussian potential.
+% pot = scgcpot(cheadsize, ctailsize, p, A, B, C)
+%
+% cheadsize is the demension of head nodes.
+% ctailsize is the demension of tail nodes.
+% r = cheadsize, s = ctailsize
+% p is discrete probability.
+% A is table of r*1 vectors;
+% B is r*s matrices
+% C is r*r positive semidefinite symmetric matrices
+
+if nargin < 3
+    p = 1; 
+end
+if nargin < 4
+    A = zeros(cheadsize,1); 
+end
+if nargin < 5
+    B = zeros(cheadsize,ctailsize); 
+end
+if nargin < 6
+    C = zeros(cheadsize,cheadsize); 
+end
+
+if isempty(A)
+    A = zeros(cheadsize,1); 
+end
+if isempty(B)
+    B = zeros(cheadsize,ctailsize); 
+end
+if isempty(C)
+    C = zeros(cheadsize,cheadsize); 
+end
+  
+pot.cheadsize = cheadsize;
+pot.ctailsize = ctailsize;
+
+pot.p = p;
+pot.A = A;
+pot.B = B;
+pot.C = C;
+%if cheadsize == 0
+%   pot.A = [];
+%end
+%if ctailsize == 0
+%    pot.B = [];
+%end
+pot = class(pot, 'scgcpot');