Class KendallRankCorrelation
- java.lang.Object
-
- dev.nm.stat.descriptive.correlation.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 isKendall
in packageKendall
.
-
-
Constructor Summary
Constructors Constructor Description KendallRankCorrelation(double[] data1, double[] data2)
Construct a Kendall rank calculator initialized with two samples.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addData(double... data)
Update the statistic with more data.void
addData(double[] data1, double[] data2)
Add the given two samples.long
N()
Get the size of the sample.double
value()
Get the value of the statistic.
-
-
-
Method Detail
-
addData
public void addData(double... data)
Update the statistic with more data. Since this signature takes only a single arraydouble[]
, we concatenate the two arrays into one. For example, suppose we want to doaddData(new double[][]{ {1, 2, 3}, {4, 5, 6} });
addData(new double[]{ {1, 2, 3, 4, 5, 6} });
-
N
public long N()
Description copied from interface:Statistic
Get the size of the sample.
-
addData
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 sampledata2
- the second sample
-
-