distance_correlation#

distance_correlation(x, y, *, exponent=1, method=DistanceCovarianceMethod.AUTO, compile_mode=CompileMode.AUTO)[source]#

Usual (biased) estimator for the distance correlation.

Parameters
  • x (Array) – First random vector. The columns correspond with the individual random variables while the rows are individual instances of the random vector.

  • y (Array) – Second random vector. The columns correspond with the individual random variables while the rows are individual instances of the random vector.

  • exponent (float) – Exponent of the Euclidean distance, in the range \((0, 2)\). Equivalently, it is twice the Hurst parameter of fractional Brownian motion.

  • method (Union[DistanceCovarianceMethod, Literal['auto', 'naive', 'avl', 'mergesort']]) – Method to use internally to compute the distance covariance.

  • compile_mode (CompileMode) – Compilation mode used. By default it tries to use the fastest available type of compilation.

Returns

Value of the biased estimator of the distance correlation.

Return type

Array

See also

distance_correlation_sqr u_distance_correlation_sqr

Examples

>>> import numpy as np
>>> import dcor
>>> a = np.array([[1., 2., 3., 4.],
...               [5., 6., 7., 8.],
...               [9., 10., 11., 12.],
...               [13., 14., 15., 16.]])
>>> b = np.array([[1.], [0.], [0.], [1.]])
>>> dcor.distance_correlation(a, a)
1.0
>>> dcor.distance_correlation(a, b) 
0.5266403...
>>> dcor.distance_correlation(b, b)
1.0
>>> dcor.distance_correlation(a, b, exponent=0.5) 
0.6703214...

Examples using dcor.distance_correlation#

Usage of distance correlation

Usage of distance correlation

Usage of distance correlation
Distance correlation plot

Distance correlation plot

Distance correlation plot