%==============================================================================
%    zscores.m
%    Copyright (C) 2007  Denise M. Wolf, dmwolf@lbl.gov
%
%    This program is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with this program.  If not, see <http://www.gnu.org/licenses/>.
%===============================================================================
function [Z,Ireal,mean_Irand,std_Irand]=zscores(CLUSTERS,CLASSES)

k=length(CLUSTERS);
A=CLUSTERS;
B=CLASSES;
[HA,HB,HAB,IAB]=mut_info(A,B);
Ireal=IAB;

for i=1:1000
    Per=randperm(k);
    B=CLASSES(Per);
    [HA,HB,HAB,IAB]=mut_info(A,B);
    Irand(i)=IAB;
end

mean_Irand=mean(Irand);
std_Irand=std(Irand);
Z=(Ireal-mean_Irand)/std_Irand;




