about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/learning/mk_tetrad_data_file.m
blob: 9c556556ae6fe102e32e5222de1f33891d54f7ea (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
function mk_tetrad_data_file(filename, samples, sig)
% MK_TETRAD_DATA_FILE Make a file containing raw discrete data for input to TETRAD
% mk_tetrad_data_file(filename, samples, sig)
%
% samples(i,j) is the value for case i, variable j
% The resulting file can be used for the 'build' part of Tetrad.
% For details on tetrad, see hss.cmu.edu/html/departments/philosophy/TETRAD/tetrad.html

[nsamples N] = size(samples);

fid = fopen(filename, 'w');
fprintf(fid, '/Raw\n');
fprintf(fid, '%d\n', nsamples);
for i=1:N
  fprintf(fid, 'x%d ', i);
end
fprintf(fid, '\n');
for i=1:nsamples
  fprintf(fid, '%d ', samples(i,:)-1); % tetrad counts from 0
  fprintf(fid, '\n');
end
%fprintf(fid, '/Knowledge\n');
%fprintf(fid, 'Significance %4.2f\n', sig);
fclose(fid);