Skip to content

Instantly share code, notes, and snippets.

@kryton
Created October 8, 2012 06:22
Show Gist options
  • Save kryton/3851005 to your computer and use it in GitHub Desktop.
Save kryton/3851005 to your computer and use it in GitHub Desktop.
Print Factor
% Copyright (C) Daphne Koller, Stanford University, 2012
function [] = PrintFactor(F)
% Pretty print the factor F.
% The first row lists the variables and subsequent rows are
% the joint assignment and their associated factor value in
% the last column.
for i=1:length(F.var)
fprintf(1, '%d\t', F.var(i));
end
fprintf(1, '\n');
for i=1:length(F.val)
A = IndexToAssignment(i, F.card);
for j=1:length(A)
fprintf(1, '%d\t', A(j));
end
fprintf(1, '%f\n', F.val(i));
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment