Class HoeffdingsD

  • All Implemented Interfaces:
    Dependence

    @Reference(authors="W. Hoeffding",
               title="A non-parametric test of independence",
               booktitle="The Annals of Mathematical Statistics 19",
               url="http://www.jstor.org/stable/2236021",
               bibkey="journals/mathstat/Hoeffding48")
    public class HoeffdingsD
    extends java.lang.Object
    implements Dependence
    Calculate Hoeffding's D as a measure of dependence.

    References:

    W. Hoeffding:
    A non-parametric test of independence
    The Annals of Mathematical Statistics 19:546–57

    The resulting value is scaled by 30, so it is in the range [-.5;1].

    Since:
    0.7.0
    Author:
    Yinchong Yang, Erich Schubert
    • Field Detail

      • STATIC

        public static final HoeffdingsD STATIC
        Static instance.
      • TABVAL

        private static final double[] TABVAL
      • TABPOS

        private static final double[] TABPOS
    • Constructor Detail

      • HoeffdingsD

        protected HoeffdingsD()
        Constructor - use STATIC instance.
    • Method Detail

      • dependence

        public <A,​B> double dependence​(NumberArrayAdapter<?,​A> adapter1,
                                             A data1,
                                             NumberArrayAdapter<?,​B> adapter2,
                                             B data2)
        Description copied from interface: Dependence
        Measure the dependence of two variables.

        This is the more flexible API, which allows using different internal data representations.

        Specified by:
        dependence in interface Dependence
        Type Parameters:
        A - First array type
        B - Second array type
        Parameters:
        adapter1 - First data adapter
        data1 - First data set
        adapter2 - Second data adapter
        data2 - Second data set
        Returns:
        Dependence measure
      • computeBivariateRanks

        protected static <A,​B> double[] computeBivariateRanks​(NumberArrayAdapter<?,​A> adapter1,
                                                                    A data1,
                                                                    NumberArrayAdapter<?,​B> adapter2,
                                                                    B data2,
                                                                    int len)
        Compute bivariate ranks.

        q[i] is the number of objects such that x[j] < x[i] and y[j] < y[i]

        Parameters:
        adapter1 - First adapter
        data1 - First data set
        adapter2 - Second adapter
        data2 - Second data set
        len - Length
        Returns:
        Bivariate rank statistics.
      • toPValue

        public double toPValue​(double d,
                               int n)
        Convert Hoeffding D value to a p-value.
        Parameters:
        d - D value
        n - Data set size
        Returns:
        p-value