annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tree_CPD/tree_CPD.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function CPD = tree_CPD(varargin)
wolffd@0 2 %DTREE_CPD Make a conditional prob. distrib. which is a decision/regression tree.
wolffd@0 3 %
wolffd@0 4 % CPD =dtree_CPD() will create an empty tree.
wolffd@0 5
wolffd@0 6 if nargin==0
wolffd@0 7 % This occurs if we are trying to load an object from a file.
wolffd@0 8 CPD = init_fields;
wolffd@0 9 clamp = 0;
wolffd@0 10 CPD = class(CPD, 'tree_CPD', discrete_CPD(clamp, []));
wolffd@0 11 return;
wolffd@0 12 elseif isa(varargin{1}, 'tree_CPD')
wolffd@0 13 % This might occur if we are copying an object.
wolffd@0 14 CPD = varargin{1};
wolffd@0 15 return;
wolffd@0 16 end
wolffd@0 17
wolffd@0 18 CPD = init_fields;
wolffd@0 19
wolffd@0 20
wolffd@0 21 clamped = 0;
wolffd@0 22 fam_sz = [];
wolffd@0 23 CPD = class(CPD, 'tree_CPD', discrete_CPD(clamped, fam_sz));
wolffd@0 24
wolffd@0 25
wolffd@0 26 %%%%%%%%%%%
wolffd@0 27
wolffd@0 28 function CPD = init_fields()
wolffd@0 29 % This ensures we define the fields in the same order
wolffd@0 30 % no matter whether we load an object from a file,
wolffd@0 31 % or create it from scratch. (Matlab requires this.)
wolffd@0 32
wolffd@0 33 %init the decision tree set the root to null
wolffd@0 34 CPD.tree.num_node = 0;
wolffd@0 35 CPD.tree.root=1;
wolffd@0 36 CPD.tree.nodes=[];
wolffd@0 37