function CPT = CPT_from_fn(fname, psizes, self_size)
% CPT_FROM_FN Represent a function as a conditional probability table
% CPT = CPT_from_fn(fname, psizes, self_size)

CPT = zeros(prod(psizes), self_size);
pvals = zeros(1, length(ps));
for i=1:prod(psizes)
  pvals = ind2subv(psizes, i);
  x = feval(fname, pvals);
  CPT(i, x) = 1;
end
CPT = reshape(CPT, [psizes self_size]);
