diff toolboxes/FullBNT-1.0.7/bnt/potentials/determine_pot_type.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolboxes/FullBNT-1.0.7/bnt/potentials/determine_pot_type.m	Tue Feb 10 15:05:51 2015 +0000
@@ -0,0 +1,25 @@
+function pot_type = determine_pot_type(model, onodes, nodes)
+% DETERMINE_POT_TYPE Determine the type of potential based on the evidence pattern.
+% pot_type = determine_pot_type(model, onodes, nodes)
+%
+% If there are any utility nodes, pot_type = 'u'
+% else
+% If all hidden nodes are discrete, pot_type = 'd'.
+% If all hidden nodes are continuous, pot_type = 'g' (Gaussian).
+% If some hidden nodes are discrete, and some cts, pot_type = 'cg' (conditional Gaussian).
+%
+% nodes defaults to all nodes in graph
+
+nnodes = length(model.node_sizes);
+if nargin < 3, nodes = 1:nnodes; end
+
+hnodes = mysetdiff(nodes, onodes);
+if isfield(model, 'limid') %~isempty(model.utility_nodes)
+  pot_type = 'u';
+elseif isempty(myintersect(model.cnodes, hnodes))
+  pot_type = 'd';
+elseif mysubset(hnodes, model.cnodes)
+  pot_type = 'g';
+else
+  pot_type = 'cg';
+end