From 8070dc963753142bb86c4ed698d91fd623ed28e7 Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Thu, 28 Sep 2017 15:04:40 -0500 Subject: 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 --- .../bnt-master/BNT/learning/bayes_update_params.m | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sourcecodes/bnt-master/BNT/learning/bayes_update_params.m (limited to 'sourcecodes/bnt-master/BNT/learning/bayes_update_params.m') diff --git a/sourcecodes/bnt-master/BNT/learning/bayes_update_params.m b/sourcecodes/bnt-master/BNT/learning/bayes_update_params.m new file mode 100644 index 00000000..4a0a28f4 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/learning/bayes_update_params.m @@ -0,0 +1,38 @@ +function bnet = bayes_update_params(bnet, cases, clamped) +% BAYES_UPDATE_PARAMS Bayesian parameter updating given completely observed data +% bnet = bayes_update_params(bnet, cases, clamped) +% +% If there is a missing data, you must use EM. +% cases(i,m) is the value assigned to node i in case m (this can also be a cell array). +% clamped(i,m) = 1 if node i was set by intervention in case m (default: clamped = zeros). +% Clamped nodes are not updated. +% If there is a single case, clamped is a list of the clamped nodes, not a bit vector. + + +%if iscell(cases), usecell = 1; else usecell = 0; end + +n = length(bnet.dag); +ncases = size(cases, 2); +if n ~= size(cases, 1) + error('data must be of size nnodes * ncases'); +end + +if ncases == 1 % clamped is a list of nodes + if nargin < 3, clamped = []; end + clamp_set = clamped; + clamped = zeros(n,1); + clamped(clamp_set) = 1; +else % each row of clamped is a bit vector + if nargin < 3, clamped = zeros(n,ncases); end +end + +for i=1:n + e = bnet.equiv_class(i); + if adjustable_CPD(bnet.CPD{e}) + u = find(clamped(i,:)==0); + ps = parents(bnet.dag, i); + bnet.CPD{e} = bayes_update_params(bnet.CPD{e}, cases(i,u), cases(ps,u)); + end +end + + -- cgit 1.4.1