Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/marg_table.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function smallT = marg_table(bigT, bigdom, bigsz, onto, maximize) |
matthiasm@8 | 2 % MARG_TABLE Marginalize a table |
matthiasm@8 | 3 % smallT = marg_table(bigT, bigdom, bigsz, onto, maximize) |
matthiasm@8 | 4 |
matthiasm@8 | 5 if nargin < 5, maximize = 0; end |
matthiasm@8 | 6 |
matthiasm@8 | 7 |
matthiasm@8 | 8 smallT = myreshape(bigT, bigsz); % make sure it is a multi-dim array |
matthiasm@8 | 9 sum_over = mysetdiff(bigdom, onto); |
matthiasm@8 | 10 ndx = find_equiv_posns(sum_over, bigdom); |
matthiasm@8 | 11 if maximize |
matthiasm@8 | 12 for i=1:length(ndx) |
matthiasm@8 | 13 smallT = max(smallT, [], ndx(i)); |
matthiasm@8 | 14 end |
matthiasm@8 | 15 else |
matthiasm@8 | 16 for i=1:length(ndx) |
matthiasm@8 | 17 smallT = sum(smallT, ndx(i)); |
matthiasm@8 | 18 end |
matthiasm@8 | 19 end |
matthiasm@8 | 20 |
matthiasm@8 | 21 |
matthiasm@8 | 22 ns = zeros(1, max(bigdom)); |
matthiasm@8 | 23 %ns(bigdom) = mysize(bigT); % ignores trailing dimensions of size 1 |
matthiasm@8 | 24 ns(bigdom) = bigsz; |
matthiasm@8 | 25 |
matthiasm@8 | 26 smallT = squeeze(smallT); % remove all dimensions of size 1 |
matthiasm@8 | 27 smallT = myreshape(smallT, ns(onto)); % put back relevant dims of size 1 |