# HG changeset patch
# User Zoltan Szabo
# Date 1353360234 3600
# Node ID 0da37f919f4c083345519b6cc4c7cc63987af9ef
# Parent ff6ce98a7c0204ed00fc514ae01df00dfd54b20f
'IGV_estimation.m': added (#2); documentation: modified accordingly.
diff git a/CHANGELOG.txt b/CHANGELOG.txt
 a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ 1,3 +1,5 @@
+IGV_estimation: added (#2); documentation: modified accordingly.
+
v0.20 (Nov 19, 2012):
Two Shannon entropy estimators based on the distance (KL divergence) from the uniform/Gaussian distributions: added; see 'HShannon_DShannon_U_initialization.m', 'HShannon_DShannon_U_estimation.m', 'HShannon_DShannon_N_initialization.m', 'HShannon_DShannon_N_estimation.m'.
Shannon entropy estimator based on Voronoi regions: added; see 'HShannon_Voronoi_initialization.m', 'HShannon_Voronoi_estimation.m'.
diff git a/code/H_I_D/base_estimators/IGV_estimation.m b/code/H_I_D/base_estimators/IGV_estimation.m
new file mode 100644
 /dev/null
+++ b/code/H_I_D/base_estimators/IGV_estimation.m
@@ 0,0 +1,50 @@
+function [I] = IGV_estimation(Y,ds,co)
+%Estimates the generalized variance (I).
+%
+%INPUT:
+% Y: Y(:,t) is the t^th sample.
+% ds: subspace dimensions.
+% co: initialized mutual information estimator object.
+%REFERENCE:
+% Zoltan Szabo and Andras Lorincz. Real and Complex Independent Subspace Analysis by Generalized Variance. ICA Research Network International Workshop (ICARN), pages 8588, 2006.
+%
+%Copyright (C) 2012 Zoltan Szabo ("http://nipg.inf.elte.hu/szzoli", "szzoli (at) cs (dot) elte (dot) hu")
+%
+%This file is part of the ITE (Information Theoretical Estimators) Matlab/Octave toolbox.
+%
+%ITE 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 software 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 ITE. If not, see .
+
+%co.mult:OK.
+
+if one_dimensional_problem(ds) && length(ds)==2
+ %initialization:
+ fs = IGV_dependency_functions;
+ num_of_functions = length(fs);
+ num_of_samples = size(Y,2);
+ I = 0;
+ %query for the current working environment:
+ environment_Matlab = working_environment_Matlab;
+
+ %I computation:
+ for k = 1 : num_of_functions %pick the k^th function (fs{k})
+ fY = feval(fs{k},Y).';
+ if strcmp(co.dependency,'cov')
+ c = (fY(:,1)mean(fY(:,1))).' * (fY(:,2)mean(fY(:,2))) / (num_of_samples1);
+ I = I + c.^2; %cov instead of corr
+ else %corr/cor
+ if environment_Matlab%Matlab
+ I = I + (corr(fY(:,1),fY(:,2))).^2; %corr instead of cov
+ else%Octave
+ I = I + (cor(fY(:,1),fY(:,2))).^2; %cor (and not 'corr') instead of cov
+ end
+ end
+ end
+else
+ error('There must be 2 pieces of onedimensional subspaces (coordinates) for this estimator.');
+end
diff git a/code/H_I_D/base_estimators/IGV_initialization.m b/code/H_I_D/base_estimators/IGV_initialization.m
 a/code/H_I_D/base_estimators/IGV_initialization.m
+++ b/code/H_I_D/base_estimators/IGV_initialization.m
@@ 4,8 +4,6 @@
%Note:
% 1)The estimator is treated as a cost object (co).
% 2)We make use of the naming convention 'I_initialization', to ease embedding new mutual information estimation methods.
% 3)For GV, the corresponding 'IGV_estimation.m' procedure has not been implemented, since GV is used in case of cost_type = 'Ipairwise1d', where the similarity matrix can be computed more
% efficiently for GV (see 'I_similarity_matrix.m').
%
%INPUT:
% mult: is a multiplicative constant relevant (needed) in the estimation; '=1' means yes, '=0' no.
diff git a/code/H_I_D/utilities/IGV_dependency_functions.m b/code/H_I_D/utilities/IGV_dependency_functions.m
new file mode 100644
 /dev/null
+++ b/code/H_I_D/utilities/IGV_dependency_functions.m
@@ 0,0 +1,23 @@
+function [fs] = IGV_dependency_functions()
+%Creates functions for measuring fcovariance / fcorrelation for the generalized variance (GV) measure.
+%
+%OUTPUT:
+% fs: cell array; Assumption: elements of fs can be applied by feval to a matrix (e.g.: functions operating coordinatewise).
+%
+%Copyright (C) 2012 Zoltan Szabo ("http://nipg.inf.elte.hu/szzoli", "szzoli (at) cs (dot) elte (dot) hu")
+%
+%This file is part of the ITE (Information Theoretical Estimators) Matlab/Octave toolbox.
+%
+%ITE 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 software 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 ITE. If not, see .
+
+f1 = 'cos';
+f2 = @(t)cos(2*t); %Matlab7
+%f2 = inline('cos(2*t)','t'); %Matlab6
+
+fs = {f1,f2};
diff git a/code/H_I_D/utilities/IGV_similarity_matrix.m b/code/H_I_D/utilities/IGV_similarity_matrix.m
 a/code/H_I_D/utilities/IGV_similarity_matrix.m
+++ b/code/H_I_D/utilities/IGV_similarity_matrix.m
@@ 19,7 +19,7 @@
%You should have received a copy of the GNU General Public License along with ITE. If not, see .
%initialization:
 fs = GV_dependency_functions;
+ fs = IGV_dependency_functions;
num_of_functions = length(fs);
C = zeros(size(Y,1));
%query for the current working environment:
@@ 37,16 +37,3 @@
end
end
end

%
function [fs] = GV_dependency_functions()
%Creates functions for measuring fcovariance / fcorrelation.
%
%OUTPUT:
% fs: cell array; Assumption: elements of fs can be applied by feval to a matrix (e.g.: functions operating coordinatewise).

f1 = 'cos';
f2 = @(t)cos(2*t); %Matlab7
%f2 = inline('cos(2*t)','t'); %Matlab6

fs = {f1,f2};
\ No newline at end of file