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 (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)\).

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

  • estimation_stat (Union[EstimationStatistic, Literal['U', 'V', 'u_statistic', 'v_statistic']]) – 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

Array

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