about summary refs log tree commit diff
path: root/sourcecodes/parameter_learning/checkDiscreteNodes.m
blob: c9d0692c4f4e3ddbaa76c22b426d4adf7a207d54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [ ] = checkDiscreteNodes( bnet, cases)
    %checkDiscreteNodes Checks if states of discrete nodes are be integers from 1 to M
    %   where M is the number of states of the node.  (M should be the same as
    %   node_sizes in the bnet).
    % 
    %Input:
    %   bnet: BNT bnet
    %   cases: cell array of data
    %
%
node_sizes = bnet.node_sizes;
dnodes = bnet.dnodes;
ndisc = size(dnodes,2);
ncases = size(cases,2);

%check to see that all data for discrete nodes are integers
for i = 1:ndisc
    inode = dnodes(i);
    data = cases(inode,:);
    isize = node_sizes(inode);
    states = zeros(1,isize);
    for j = 1:isize
        states(j) = j;
    end
    for j = 1:ncases
        k = int64(data{j});
        if ~any(k==states)
            error(['Discrete nodes must be integers from 1 to the number of states']);
        end
    end
end

    
end