annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@root_CPD/convert_to_pot.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function pot = convert_to_pot(CPD, pot_type, domain, evidence)
Daniel@0 2 % CONVERT_TO_POT Convert a root CPD to one or more potentials
Daniel@0 3 % pots = convert_to_pot(CPD, pot_type, domain, evidence)
Daniel@0 4
Daniel@0 5 assert(length(domain)==1);
Daniel@0 6 assert(~isempty(evidence(domain)));
Daniel@0 7 T = 1;
Daniel@0 8
Daniel@0 9 sz = CPD.sizes;
Daniel@0 10 ns = zeros(1, max(domain));
Daniel@0 11 ns(domain) = sz;
Daniel@0 12
Daniel@0 13 switch pot_type
Daniel@0 14 case 'u',
Daniel@0 15 pot = upot(domain, 1, T, 0);
Daniel@0 16 case 'd',
Daniel@0 17 ns(domain) = 1;
Daniel@0 18 pot = dpot(domain, ns(domain), T);
Daniel@0 19 case {'c','g'},
Daniel@0 20 ns(domain) = 0;
Daniel@0 21 pot = cpot(domain, ns(domain), 0);
Daniel@0 22 case 'cg',
Daniel@0 23 ddom = [];
Daniel@0 24 cdom = domain; % we assume the root node is cts
Daniel@0 25 %pot = cgpot(ddom, cdom, ns, {cpot([],[],0)});
Daniel@0 26 pot = cgpot(ddom, cdom, ns);
Daniel@0 27 end
Daniel@0 28