File Exchange

## Distance correlation

version 1.0 (1.48 KB) by

Distance correlation calculation

Updated

This function calculates the distance correlation between two samples x and y.

It is especially useful when x and y have weak linear dependence but strong nonlinear dependence.

For example, if
x = -10:10; x = x'
y = x.^2;
then corr(x,y) is approximately zero. However, the distance correlation between x and y is nearly 0.5.

Note: distance correlation is zero if and only if x and y are statistically independent.

Author: Shen Liu
Date: 18/01/2013
Reference: http://en.wikipedia.org/wiki/Distance_correlation

jhgang

Shaun Shi

### Shaun Shi (view profile)

I encountered "out of memory" error for large size of array input.Is there any possibility to optimize this function to mobilize larger size of array?

Paolo Inglese

Jorge

### Jorge (view profile)

What is he reason for validation of dimension?

Jorge

### Jorge (view profile)

What is he reason for validation of dimension?

precuneus

### precuneus (view profile)

Using bsxfun you could get this function more efficient, e.g.
A = a - bsxfun(@plus,mean(a),mean(a,2))+mean(a(:));

##### MATLAB Release
MATLAB 7.14 (R2012a)
##### Acknowledgements

Inspired: dcorr( X, Y )

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

Play today