Commits

Zoltan Szabo committed 98e0522

Handling of identically constant random variables in distance correlation computation: included; see 'IdCor_estimation.m'.

Comments (0)

Files changed (2)

+-Handling of identically constant random variables in distance correlation computation: included; see 'IdCor_estimation.m'.
+
 v0.26 (Dec 22, 2012):
 -Distance covariance estimation via HSIC: added; see IdCov_IHSIC_initialization.m', 'IdCov_IHSIC_estimation.m'.
 -Energy distance estimation via MMD: added; see 'DEnergyDist_DMMD_initialization.m', 'DEnergyDist_DMMD_estimation'.

code/H_I_D_A_C/base_estimators/IdCor_estimation.m

 A = compute_dCov_dCor_statistics(Y(1:ds(1),:),co.alpha);
 B = compute_dCov_dCor_statistics(Y(ds(1)+1:ds(1)+ds(2),:),co.alpha);
 
-I = sum(sum(A.*B)) / sqrt(sum(sum(A.^2)) * sum(sum(B.^2))); %<A,B> / sqrt(<A,A><B,B>)
-I = sqrt(I);
+n = sum(sum(A.*B)); %numerator
+d1 = sum(sum(A.^2));%denumerator-1 (without sqrt)
+d2 = sum(sum(B.^2));%denumerator-2 (without sqrt)
 
+if (d1*d2)==0 %(at least) one of the random variables is constant
+    I = 0;
+else
+    I = n/sqrt(d1*d2); %<A,B> / sqrt(<A,A><B,B>)
+    I = sqrt(I);
+end
 
 
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.