about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/SLP/examples/test_chisquare.m
diff options
context:
space:
mode:
authorziejd22017-09-28 15:04:40 -0500
committerziejd22017-09-28 15:04:40 -0500
commit8070dc963753142bb86c4ed698d91fd623ed28e7 (patch)
treed0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/SLP/examples/test_chisquare.m
parent7cc31810d53176e805532b2789955f4eedbce6bb (diff)
downloadBNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning.

I am calling this BNW_1.02. It can be accessed at:
compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/SLP/examples/test_chisquare.m')
-rw-r--r--sourcecodes/bnt-master/SLP/examples/test_chisquare.m61
1 files changed, 61 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/SLP/examples/test_chisquare.m b/sourcecodes/bnt-master/SLP/examples/test_chisquare.m
new file mode 100644
index 00000000..5282f1b0
--- /dev/null
+++ b/sourcecodes/bnt-master/SLP/examples/test_chisquare.m
@@ -0,0 +1,61 @@
+%
+% test CHI2
+%
+
+% Génération de données jouet
+N=20000;
+xx=5*rand(N,1);
+yy=5*rand(N,1);
+zz = 5*rand(N,1);
+z2= (xx+yy) ;
+Data=1+[round(xx) round(yy) round(z2) round(zz)];
+Data=Data';
+
+texte{1}='dependency';
+texte{2}='independency';
+
+%test='pearson'; % Pearson's Chi2
+test='LRT';     % Likelihood ratio test G2
+
+fprintf('\n\n\n\t=================================================\n');
+fprintf('\t\tChi2 Test for (conditional) independency\n');
+fprintf('\t\t(X, Y and Z are theoritically independant)\n');
+
+fprintf('\t=================================================\n');
+fprintf('Variables \t\t: Theory :   Results        (test=%s)\n',test);
+fprintf('------------------------------------------------------------------------\n');
+
+S=[];
+x=1; y=2;
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data(:,1:100),test);
+fprintf('X, Y \t\t\t: DEPDCY : \tCHI2=%8.2f \t%s (not enough data)\n',CHI2,texte{IND+1});
+
+S=[];
+x=1; y=2;
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data,test);
+fprintf('X, Y \t\t\t: INDPCY : \tCHI2=%8.2f \t%s\n',CHI2,texte{IND+1});
+
+S=[];
+x=1; y=3;
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data,test);
+fprintf('X, X+Y \t\t\t: DEPDCY :\tCHI2=%8.2f \t%s\n',CHI2,texte{IND+1});
+
+S=[];
+x=1; y=4;
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data,test);
+fprintf('X, Z \t\t\t: INDPCY :\tCHI2=%8.2f \t%s\n',CHI2,texte{IND+1});
+
+
+x=1; y=2; S=4;
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data,test);
+fprintf('X, Y | Z \t\t: INDPCY : \tCHI2=%8.2f \tconditional %s\n',CHI2,texte{IND+1});
+
+x=1; y=2; S=3;
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data,test);
+fprintf('X, Y | X+Y \t\t: DEPDCY : \tCHI2=%8.2f \tconditional %s\n',CHI2,texte{IND+1});
+
+x=1; y=2; S=[3 4];
+[IND CHI2] = cond_indep_chisquare(x,y,S,Data,test);
+fprintf('X, Y | {X+Y,Z}\t\t: DEPDCY : \tCHI2=%8.2f \tconditional %s\n',CHI2,texte{IND+1});
+
+fprintf('------------------------------------------------------------------------\n');
\ No newline at end of file