Class KendallRankCorrelation

• All Implemented Interfaces:
Statistic

public class KendallRankCorrelation
extends Object
implements Statistic
The Kendall rank correlation coefficient, commonly referred to as Kendall's tau (τ) coefficient, is a statistic used to measure the association between two measured quantities. A tau test is a non-parametric hypothesis test which uses the coefficient to test for statistical dependence. Specifically, it is a measure of rank correlation, that is, the similarity of the orderings of the data when ranked by each of the quantities.

Specifically, for each pair of observations $$(x_i, y_i), (x_j, y_j)$$ we say that they are concordant if either $$x_i > x_j$$ and $$y_i > y_j$$ or $$x_i < x_j$$ and $$y_i < y_j$$. Otherwise, they are said to be discordant.

Kendall's tau is defined as: $\tau = \frac{(\text{no. of concordant pairs}) - (\text{no. of discordant pairs})}{\frac{1}{2} n (n-1) }$

If the values in $$x$$ and $$y$$ are not unique, (τ - b) is computed.

This class implements the O(n log n) algorithm from Knight, W. (1966). "A Computer Method for Calculating Kendall's Tau with Ungrouped Data".

The R equivalent function is Kendall in package Kendall.

Wikipedia: Kendall tau rank correlation coefficient
• Constructor Summary

Constructors
Constructor Description
KendallRankCorrelation​(double[] data1, double[] data2)
Construct a Kendall rank calculator initialized with two samples.
• Method Summary

All Methods
Modifier and Type Method Description
void addData​(double... data)
Update the statistic with more data.
void addData​(double[] data1, double[] data2)
long N()
Get the size of the sample.
double value()
Get the value of the statistic.
• Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• Constructor Detail

• KendallRankCorrelation

public KendallRankCorrelation​(double[] data1,
double[] data2)
Construct a Kendall rank calculator initialized with two samples. The size of the two sample must be equal.
Parameters:
data1 - the first sample
data2 - the second sample
• Method Detail

public void addData​(double... data)
Update the statistic with more data. Since this signature takes only a single array double[], we concatenate the two arrays into one.

For example, suppose we want to do

 
{1, 2, 3},
{4, 5, 6}
});


We can also write
 
{1, 2, 3, 4, 5, 6}
});


In the latter case, there must be an even number of data points.
Specified by:
addData in interface Statistic
Parameters:
data - a data array concatenating two samples
• N

public long N()
Description copied from interface: Statistic
Get the size of the sample.
Specified by:
N in interface Statistic
Returns:
the sample size

public void addData​(double[] data1,
double[] data2)
Add the given two samples. The size of the two samples must be equal.
Parameters:
data1 - the first sample
data2 - the second sample
• value

public double value()
Description copied from interface: Statistic
Get the value of the statistic.
Specified by:
value in interface Statistic
Returns:
the statistic