dcor.homogeneity.energy_test_statistic

energy_test_statistic(x, y, *, exponent=1, average=None, estimation_stat=EstimationStatistic.V_STATISTIC)[source]

Homogeneity statistic.

Computes the statistic for homogeneity based on the energy distance, for random vectors corresponding to \(x\) and \(y\).

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

  • y (T) – 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)\).

  • average (Callable[[T], T] | None) – A function that will be used to calculate an average of distances. This defaults to np.mean.

  • estimation_stat (EstimationStatisticLike) – If EstimationStatistic.U_STATISTIC, calculate energy distance using Hoeffding’s unbiased U-statistics. Otherwise, use von Mises’s biased V-statistics. If this is provided as a string, it will first be converted to an EstimationStatistic enum instance.

Returns

Value of the statistic for homogeneity based on the energy distance.

Return type

T

See also

energy_distance

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],
...               [0, 1, 1, 1],
...               [1, 1, 1, 1]])
>>> dcor.homogeneity.energy_test_statistic(a, a)
0.0
>>> dcor.homogeneity.energy_test_statistic(a, b) 
35.2766732...
>>> dcor.homogeneity.energy_test_statistic(b, b)
0.0